jquery/zepto在插件编写上的几点区别?

1. 自定义事件的命名空间

jq的时间命名空间是用点“.”,而zepto是用冒号“:”

//jquery
$(this).trigger('cusevent.pluginname');
//zepto
$(this).trigger('cusevent:pluginname');

2、data() 方法

jq的data方法非常强大,可以存储字符串、对象、函数等一切js数据

而zepto的data方法相对要少一些:官方文档为:Zepto's basic implementation of `data()` only stores strings. To store arbitrary objects, include the optional "data" module in your custom build of Zepto.

翻译过来就是:Zepto的基本实现` data() `只存储字符串。存储任意对象,包括在您的自定义可选的“数据”模块建立Zepto。

由于写插件时,常用data方法来缓存插件实例化后的内容。