zoukankan      html  css  js  c++  java
  • Zepto的使用以及注意事项

       为什么选择Zepto.js的原因:

    1.   zepto.js的语法借鉴并且兼容jQuery,会使用jquery就会使用Zepto.js。Zepto.js是移动端的js库。Zepto.js相当于PC端的jQuery,它提供了很多方法和功能,能够很快的实现各种需求和功能。使用Zepto.js开发,性能上是最好的,而兼容性比较好,跟jQuery有同样的API,只是需要自己设计UI
    2.   压缩后的 zepto.min.js 大小只有24K。   
    • 绑定事件不同
    • 用 “on”来代替“bind”、“delegate”、”live”。
    • 用 “off”来代替“unbind”、“undelegate”、”die”。
    • 用 “ $.ajax”来代替“$.ajaxJSONP”。
    • 用 “tap”来代替 ”click“,因为click会有200-300ms的延迟。

       Zepto.js对 CSS 选择器的支持

      1、Zepto.js没有 .innerHeight() .outerWidth() 等四个方法。

      2、支持基本选择器

        ID选择器:$("#foo")

        class选择器:$(".foo")

        标签(元素)选择器:$("div")、$("p")。

        通用选择器:$("*")。

         3、支持层级选择器

        后代选择器:$("foo bar")。

        子元素选择器:$("foo > bar")。

        相邻且靠后选择器:$("foo + bar")。

        同辈且靠后选择器:$("foo ~ bar")。

      4、不支持的选择器

        基本伪类:

          first、:not(selector) 、:even 、:odd 、:eq(index) 、:gt(index) 、:lang1.9+ 、:last 、:lt(index) 、:header、:animated 、:focus1.6+ 、:root1.9+ 、:target1.9+

        内容伪类::contains(text) 、:empty、 :has(selector)、 :parent 。

        可见性伪类::hidden 、:visible 。

        属性选择器:[attribute!=value]。

        表单伪类::input、 :text、 :password、 :radio、 :checkbox、 :submit、 :image、 :reset、 :button、 :file、 :hidden 。

        表单对象属性::selected。

       Touch 事件

        tap —元素tap的时候触发。

        singleTap and doubleTap — 这一对事件可以用来检测元素上的单击和双击。(如果你不需要检测单击、双击,使用 tap 代替)。

        longTap — 当一个元素被按住超过750ms触发。

        swipe, swipeLeft, swipeRight, swipeUp, swipeDown — 当元素被划过时触发。(可选择给定的方向)

  • 相关阅读:
    杭电1029--Ignatius and the Princess IV(哈希)
    杭电1465--不容易系列之一
    杭电1021--Fibonacci Again
    杭电5018--Revenge of Fibonacci
    UVa10651(记忆化搜索)
    <Win32_5>深入浅出Win32的计时器
    偷个空,写个博客——各种沟通各种纠结
    Arbitrage HDU
    常用的字符串处理方法
    无法捕获的异常:MissingMethodException
  • 原文地址:https://www.cnblogs.com/weiyf/p/8696396.html
Copyright © 2011-2022 走看看