Vue.js Javascript从列表中删除
我有一个Vue.js Javascript从列表中删除,javascript,vue.js,Javascript,Vue.js,我有一个投票用户数组。现在我想删除一个用户 根据他的身份证 role: 2 active: 2 about: null id: 3 email: "test@gmail.com.com" created_at: "2016-11-08 17:14:16" function: "functie...." last_name: "Janssen" mobile: "6" pivot: Object updated_at: "2016-11-08 17:30:20" 方法: option.votes
投票
用户数组。现在我想删除一个用户
根据他的身份证
role: 2
active: 2
about: null
id: 3
email: "test@gmail.com.com"
created_at: "2016-11-08 17:14:16"
function: "functie...."
last_name: "Janssen"
mobile: "6"
pivot: Object
updated_at: "2016-11-08 17:30:20"
方法:
option.votes.$remove($root.user.id);
显然,这是行不通的。我如何让它工作?试试这个:
newArray = myArray.filter(function( obj ) {
return obj.id !== 'idToDelete';
});
option.votes = newArray
试试这个:
newArray = myArray.filter(function( obj ) {
return obj.id !== 'idToDelete';
});
option.votes = newArray
您正在使用vue 2.0吗
$remove
在2.0中已被弃用。您是否使用vue 2.0<代码>$remove在2.0中已被弃用。