jQuery.makePlugin构造函数方式轻松构建jQuery插件
JQuery.make插件使用构造函数轻松构建jQuery插件。通过运行 bower install jquery-makeplugin
来安装依赖。假设你有一个 JavaScript 类,如下所示:
var MyClass = function($container, options) {
this.$container = $container;
this.options = options;
};
然后你可以扩展类的原型方法:
$.extend(MyClass.prototype, {
$: function(selector) {
// 使用 this.$() 快捷方法在指定元素内查找查询
return this.$container.find(selector);
},
// 其他插件方法
});
下载地址
用户评论