console
cola(function (model) {
model.set("person", {
name: "John",
age: "25",
gender: "male",
address: {
city: "Shanghai",
district: "Pudong",
street: "Dongfang Road",
zipCode: "200000"
}
});
model.action({
getAndSet: function(){
model.set("person.name", "Mike");
cola.alert(model.get("person.name"));
},
batchSet: function() {
model.set("person", {
name: "Jane",
age: "23",
gender: "female",
address: {
city: "Beijing",
district: "Chaoyang",
street: "Jiangtai Road",
zipCode: "100020"
}
});
}
});
});
<c-button c-onclick="getAndSet()">简单的读写</c-button>
<c-button c-onclick="batchSet()">批量写属性</c-button>
<hr>
<div>
<label>Name: </label>
<c-label c-bind="person.name"></c-label>
</div>
<div>
<label>Age: </label>
<c-label c-bind="person.age"></c-label>
</div>
<div>
<label>Gender: </label>
<c-label c-bind="person.gender"></c-label>
</div>
<div>
<label>City: </label>
<c-label c-bind="person.address.city"></c-label>
</div>
<div>
<label>District: </label>
<c-label c-bind="person.address.district"></c-label>
</div>
<div>
<label>Street: </label>
<c-label c-bind="person.address.street"></c-label>
</div>
label {
display: inline-block;
width: 5em;
text-align: right;
padding: 0.5em;
color: grey;
}