The code looks like this:
<div > <input v-model="inputValue"> <button @click="handleSumbit">submit</button> <todo-item v-for="(item,index) of list":key="index":content="item":index="index" @delete="handleDelete"></todo-item> </div>
Subcomponents pass data to parent componentsthis.$emit('delete',)
This method
<script > ('todo-item',{ props:["content",'index'], template:"<li @click='handleSubmit'>{{content}}{{index}}</li>", methods:{ handleSubmit:function () { this.$emit('delete',) } } }) new Vue({ el:'#app', data:{ inputValue:'', list:[] }, methods:{ handleSumbit:function () { (); =""; }, handleDelete:function (index) { (index,1) } } }) </script>
Summarize
The above is the Vue implementation of todolist deletion function introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!