<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>数据更新</title>
<script src="js/avalon.js"></script>
<script>
var model = avalon.define({
$id:"test",
data:{
aaa:1111,
bbb:2222,
ccc:3333,
ddd:4444
},
array_1:["a","b","c"],
array_2:[
{text:"a"},
{text:"b"},
{text:"c"}
]
});
//对象数据-键值的更新
setTimeout(function () {
model.data.aaa = 5555;
},2000);
//对象数据-键值对的更新
setTimeout(function () {
model.data ={
eee:6666,
fff:7777,
ggg:8888
}
},4000);
//数组数据简单值的更新
setTimeout(function () {
model.array_1.set(1,"bbbb");
},6000);
//数组数据-对象值的更新
setTimeout(function () {
model.array_2[0].text = "aaaa";
},8000)
</script>
</head>
<body ms-controller="test">
<h1>数据的更新</h1>
<ul>
<li ms-repeat="data">{{$key}}--{{$val}}</li>
</ul>
<ul>
<li ms-repeat="array_1">{{el}}</li>
</ul>
<ul>
<li ms-repeat="array_2">{{el.text}}</li>
</ul>
</body>
</html>