Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除Vue.js中计算列表的一项_Vue.js - Fatal编程技术网

删除Vue.js中计算列表的一项

删除Vue.js中计算列表的一项,vue.js,Vue.js,我需要显示项目列表,并能够在需要时删除其中一项 <tr v-for="(todo, key, index) in todo_list"> <td><input v-model.trim="todo.priority" type="number"/></td> <td><a v-on:click="todo_list.splice(index, 1)">Delete</a></td>

我需要显示项目列表,并能够在需要时删除其中一项

  <tr v-for="(todo, key, index) in todo_list">
    <td><input v-model.trim="todo.priority" type="number"/></td>
    <td><a v-on:click="todo_list.splice(index, 1)">Delete</a></td>
  </tr>

删除
这里的问题是todo_列表是计算出来的。多亏了v型,我可以编辑优先级。我可以注意到这一点。但我想能够删除任何项目太。它不会触发任何错误或警告(vue.js文件未缩小)

我尝试了
Vue.delete(todo_列表,索引)
,我尝试传递键而不是索引,以便在方法中执行此操作。这些都不管用。注意:当我尝试该方法时,我输入了:我可以在
拼接前后登录控制台


我可以在数据中创建一个反映计算值的属性,但我相信这是无用的代码。有没有办法做到这一点?

如果每个todo都有一个唯一的
,只需使用这些键即可从原始数据中删除

待办事项:

{
  key: 0,
  priority: 5,
  ...
}
例如:

以及删除方法:

remove (key) {
    this.todoList = this.todoList.filter(todo => todo.key !== key)
}

您想从原始对象中删除该项,还是告诉计算机不要包含该项?您好,罗伊!我想从原始对象中删除它
remove (key) {
    this.todoList = this.todoList.filter(todo => todo.key !== key)
}