国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

Vue實現todolist刪除功能

2019-11-19 13:36:19
字體:
來源:轉載
供稿:網友

代碼如下所示:

<div id="app"> <input v-model="inputValue"> <button @click="handleSumbit">提交</button> <todo-item v-for="(item,index) of list":key="index":content="item":index="index"  @delete="handleDelete"></todo-item></div>

子組件向父組件傳遞數據使用 this.$emit('delete',this.index)該方法

<script > Vue.component('todo-item',{  props:["content",'index'],  template:"<li @click='handleSubmit'>{{content}}{{index}}</li>",  methods:{   handleSubmit:function () {    this.$emit('delete',this.index)   }  } }) new Vue({  el:'#app',  data:{   inputValue:'',   list:[]  },  methods:{   handleSumbit:function () {    this.list.push(this.inputValue);    this.inputValue="";   },   handleDelete:function (index) {    this.list.splice(index,1)   }  } })</script>

總結

以上所述是小編給大家介紹的Vue實現todolist刪除功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 绿春县| 临泉县| 田阳县| 剑川县| 临清市| 承德县| 上蔡县| 海宁市| 霞浦县| 浮梁县| 宜黄县| 海口市| 湘乡市| 铁岭市| 朝阳区| 合肥市| 三明市| 水富县| 澄江县| 石渠县| 新密市| 德兴市| 华亭县| 郧西县| 霍邱县| 鲜城| 织金县| 祁门县| 浮山县| 宝清县| 六盘水市| 澄江县| 柳州市| 遂宁市| 墨脱县| 凤台县| 岑溪市| 军事| 河池市| 南开区| 周宁县|