创建插件
可以通过添加方法作为 $.fn
的属性来写插件:
;(function($){
$.extend($.fn, {
foo: function(){
// `this` refers to the current Zepto collection.
// When possible, return the Zepto collection to allow chaining.
return this.html('bar')
}
})
})(Zepto)
为了更好开始开发插件,先看下source of Zepto's core module,并确认读过coding style guidelines