实例方法
1. get
语法: get( name ) 获取 model ( data ) 值
2. set
语法: get( name, value ) 设置 model ( data ) 值 会 触发 通过 watch(工厂函数/构造函数的参数) 或者 $watch (实例方法) 绑定的事件
var App = Vir()
var app = new App({
data: {
index: 0
},
watch: {
index: function(result) {
alert('watch:' + JSON.stringify(result))
}
}
})
app.$watch('index', function(result) {
alert('$watch:' + JSON.stringify(result))
})
app.get('index') // -> 0
app.set('index', 1) // emit index
app.get('index') // -> 1
3. $$
语法: $$( selector, [cache] ) 在 $el ( jquery 对象 ) 下查找对应 dom 可以设置 cache 为 false 清除默认缓存
4. $watch
语法: $watch(type, callback, [once]) 调用 set 方法触发 callback, once 为 true 的时候只触发一次 callback
5. on
语法: on(type, handler) 绑定事件
6. once
语法: once(type, handler) 绑定事件,只触发一次
7. off
语法: off(type, handler) 移除绑定事件
8. emit
语法: emit(type, args, ctx) 触发绑定的事件
9. getEventListeners
语法: getEventListeners(type) 获取事件列表