<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) } } }
添加回答
举报
0/150
提交
取消