绑定的指令 directive provided
```
vb-modalname="key" 组件块的modalname绑定
vb-model="key" 表单元素的双向绑定
vb-item="subKey" 数组遍历时的值绑定
vb-if vb-show vb-hide 显隐与存在
vb-value 为元素绑定添加value属性
vb-class 条件class
vb-entity 将值转化为实体
vb-cloak 解析前不显示
```
Demo1: Dead Simple Example
js
var vb1 = new ViewBind({
modelId: 'user',
$el: '#demo1',
data: { name: 'joe', age: 18 }
});
Demo2: Render List
js
var vb2 = new ViewBind({
modelId: 'user',
$el: '#demo2',
data: {
users: [{
name: 'joe', age: 18
}, {
name: 'kate', age: 22
}, {
name: 'laowang', age: 5
}]
}
});
Demo3: Render Nested List
js
var vb3 = new ViewBind({
modelId: 'user',
$el: '#demo2',
data: {
title: 'this is a Render Nested List demo',
users: [{
name: 'joe', age: 18, sex: 1,
children: [{
name: 'subjoe',
age: 5
}]
}, {
name: 'kate', age: 22, sex: 0,
children: [{
name: 'subjoe',
age: 5
}, {
name: 'everyone',
age: 3
}]
}]
},
entity: {
'sex': function(value) { return value === 1 ? 'male' : 'female'; }
}
});
Demo4: partial and global update components
partial update: vb3.set('title', 'this is updated title');
global update: vb3.set(updateVB3Data);
Demo5: Form bind
form type elements use vb-modelname="key" for bi-bind vb.data.key, and has vb-model="key2" to sync with key
Demo6: A full components code
new ViewBind({
modelId: 'user',
$el: '#root',
data: { name: 'joe', age: 18 },
entity: {
//u can alse user entity for this ViewBind or user vb-entity="value === 1 ? 'male' : 'female'"
'sex': function(value) { return value === 1 ? 'male' : 'female'; }
},
events: {
'click .user': 'setUser',
'click .pwd': function(e, elem, that) {}
},
watch:{
'age': function(newval, oldval){}
},
created: function(){}, //before render
attached: function(){}, //after render
setUser: function(e, elem) {}
});