<body>
<div id="app">
<li v-for='item in students'>
<span>{{ item.name }}</span>
<span>{{ item.age }}</span>
</li>
<button @click='addStudent'>click</button>
<button @click='$
set(students,3,{name:"xioaming",age:102333})'>click</button>
<button @click='
Vue.set(students,3,{name:"xioaming",age:102333})'>click</button>
</div>
<script src="../vue.js"></script>
<script>
var vm = new Vue({
el: '#app',
data: {
students: [
{name:"xioaming",age:10},
{name:"xioaming",age:101},
{name:"xioaming",age:102}
]
},
methods: {
addStudent: function(){
this.students[3] = {name:"xioaming",age:102333}//这样不能重新渲染页面
this.students.push({name:"xioaming",age:102333})
} } }) </script>