• 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 — 当元素被划过时触发。(可选择给定的方向)

  • 相关阅读:
    vue 富文本编译器 vue-quill-editor
    vue-拖拽的使用awe-dnd
    Dapper是什么?
    如何运用领域驱动设计
    面试官问我MySQL索引,我
    MySQL:你知道什么是覆盖索引吗?
    mysql覆盖索引与回表
    C#.NET 字符串转数组,数组转字符串
    MYSQL如何让主键使用BTREE索引
    MySQL大表优化方案 Mysql的row_format(fixed与dynamic)
  • 原文地址:https://www.cnblogs.com/weiyf/p/8696396.html
Copyright © 2020-2023  润新知