美文网首页
vue 渲染出来的数据 如何删除其中一条数据

vue 渲染出来的数据 如何删除其中一条数据

作者: 昵称啦啦啦 | 来源:发表于2018-09-16 13:29 被阅读0次
 // template 部分
<div  v-for="(index, item) in testData" :key="item.content">
  <!-- 删除函数 -->
  <div class="clear" @click="clear(index)"></div>
</div>

// js 部分
data() {
  return {
    testData: [
      { content: "1111111111111" },
      { content: "2222222222222" },
      { content: "3333333333333" }
    ]
  };
},
// methods 函数(方法)部分
clear: function(index) {
  this.testData.splice(index, 1);
}

相关文章

网友评论

      本文标题:vue 渲染出来的数据 如何删除其中一条数据

      本文链接:https://www.haomeiwen.com/subject/niaxnftx.html