Vue.component("TodoItem",{
props:['content'],
template:'\
<li>{{content}}</li>\
'
})
var vm=new Vue({
el:'#app',
data:{
list:[],
inputValue:''
},
methods:{
handleBtnClick:function(){
this.list.push(this.inputValue)
this.inputValue=''
}
}
})
<div id="app">
<input type="text" v-model="inputValue"/>
<button v-on:click="handleBtnClick">提交</button>
<ul>
<todo-item v-bind:content="item"
v-for="item in list"></todo-item>
</ul>
</div>