qui*_* 0 html javascript vue.js
我想按索引过滤对象数组。
<ul>
<li v-for="(list,index) in lists" v-bind:key="index"
@dblclick="deleteNote(index)">
{{list.note}
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
列表中充满了以下对象imp
var lists = [];
var imp = {
note: "bla",
hinweis: "blub",
showNotiz: false
};
deleteNote(i) {
let arr = this.lists.filter(item =>
item.note !== this.lists[i]
);
this.lists = arr;
}
Run Code Online (Sandbox Code Playgroud)
Ale*_*sky 17
我认为这会起作用
deleteNote(i) {
this.lists = this.lists.filter((_, index) => index !== i);
}
Run Code Online (Sandbox Code Playgroud)