轻量级的移动开发JavaScript框架:zepto.js
jopen
10年前
Zepto.js 是移动端轻量级的JavaScript框架,实现JQuery的大部分API,针对手机上web开发,轻量级的是相对性的减少用户访问流量
可以到 github上下载zepto的源码也是进行模块划分的
Zepto 思维导向图:
常用返回对象情况:
1、return zepto.Z(),返回一个空的zepto对象:
2、return $(context).find(selector)
3、return $(document).ready(selector)
4、if (zepto.isZ(selector)) return selector
5、return $(context).find(selector)
6、return zepto.Z(dom, selector)
常用方法:
1、$(selector,context?) 传入一个选择器返回一个zepto对象
2、$(function(){}) 传入一个函数,dom ready时执行
3、$(html,attrs?) 传入一个html字符串,构建元素,返回一个或zepto对象
4、$(dom obj)传入dom对象返回zepto对象
Zepto modules
module | default | description |
---|---|---|
zepto | ✔ | Core module; contains most methods |
event | ✔ | Event handling viaon()&off() |
ajax | ✔ | XMLHttpRequest and JSONP functionality |
form | ✔ | Serialize & submit web forms |
ie | ✔ | Add support for Internet Explorer 10+ on desktop and Windows Phone 8. |
detect | Provides$.osand$.browserinformation | |
fx | Theanimate()method | |
fx_methods | Animatedshow,hide,toggle, andfade*()methods. | |
assets | Experimental support for cleaning up iOS memory after removing image elements from the DOM. | |
data | A full-blowndata()method, capable of storing arbitrary objects in memory. | |
deferred | Provides$.Deferredpromises API. Depends on the "callbacks" module. When included, $.ajax() supports a promise interface for chaining callbacks. | |
callbacks | Provides$.Callbacksfor use in "deferred" module. | |
selector | Experimental jQuery CSS extensions support for functionality such as$('div:first')andel.is(':visible'). | |
touch | Fires tap– and swipe–related events on touch devices. This works with both `touch` (iOS, Android) and `pointer` events (Windows Phone). | |
gesture | Fires pinch gesture events on touch devices | |
stack | ProvidesandSelf&end()chaining methods | |
ios3 | String.prototype.trim and Array.prototype.reduce methods (if they are missing) for compatibility with iOS 3.x. |