<div id="root">
<div>
<input type="text" v-model='todoValue'>
<button @click="handleBtnClick">提交</button>
</div>
<ul>
<todo-item v-bind:content='item'
v-bind:index='index'
v-for="(item,index) in list"
@delete='handleitemDelete'>
</todo-item>
</ul>
</div>
//局部组件
var TodoItem = {
props:['content','index'],
template:'<li @click="handleItemClick">{{content}}</li>',
methods:{
handleItemClick: function(){
this.$emit('delete',this.index)
}
}
}
是狼还是哈士奇
相关分类