zoukankan      html  css  js  c++  java
  • 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方法来缓存插件实例化后的内容。 

  • 相关阅读:
    Linux_day01_primaryCommand
    Variational auto-encoder VS auto-encoder
    python yield generator 详解
    Paper Writing
    DTU_AI lecture 09
    DTU_AI lecture 08
    Attention mechanism
    Energy Journals
    TF + pytorch学习
    expRNN
  • 原文地址:https://www.cnblogs.com/wangmaoling/p/6528362.html
Copyright © 2011-2022 走看看