<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="../assets/js/vue.js"></script>
<title>Vue.set 全局操作</title>
</head>
<body>
<h1>Vue.set 全局操作</h1>
<hr>
<div id="app">
<ul>
<li v-for=" aa in arr">{{aa}}</li>
</ul>
</div>
<button onclick="add()">外部添加</button>
<script type="text/javascript">
function add(){
console.log("我已经执行了");
// Vue.set(outData,'count',4); //改变对象
app.arr[1]='ddd';
//Vue.set(app.arr,1,'ddd'); //改变数组
}
var outData={
count:2,
arr:['aaa','bbb','ccc'] //改变数组
};
var app=new Vue({
el:'#app',
data:outData
})
</script>
</body>
</html>