var app4 = new Vue({
el: '#app-4',
data: {
todos: [
{ text: '学习 JavaScript' },
{ text: '学习 Vue' },
{ text: '整个牛项目' }
],
message:'haha'
},
methods:{
click(){
this.todos.push({text:'pujie'})
console.log(this.todos)
}
}
})
<div id="app-4" >
<h4 v-for="todo in this.todos">
{{todo.text}}
</h4>
{{this.message}}
<input v-model="message"/>
<button v-on:click="click">点击</button>
</div>