console
<!DOCTYPE html>
<html lang="en">
<head>
<title>Vue.set 全局操作</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript" src="../assets/js/vue.js"></script>
</head>
<body>
<h1>Vue.set 全局操作</h1>
<hr>
<div id="app">
{{count}}
<ul>
<li v-for="item in arr">{{item}}</li>
</ul>
</div>
<p><button onclick="add()">add</button></p>
<script type="text/javascript">
function add(params) {
//Vue.set(outData, "count",++outData.count);
//app.count++;
//outData.count++;
//outData.arr[1]="ddd";//不行,js天生的弱点
Vue.set(outData.arr, 1,"dd");
}
var outData = {
count: 1,
goods: "car",
arr:["aaa","bbb","ccc"]
}
var app = new Vue({
el: '#app',
data: outData
})
</script>
</body>
</html>