这是我的小提琴:DEMO
1)在选中所有复选框时,"选择全部"应该检查。
2)选中"选择全部"后,应立即检查所有复选框。
3)选中"选择全部"后,如果取消选中一个或多个复选框,则选择全部取消选中。
如何在vuejs中完成?我找到的最接近的例子是https://jsfiddle.net/thanhmabo/atxj3786/,但无法在我的代码中使用它。
computed: {
selectAll: {
get: function () {
return this.users ? this.selected.length == this.users.length : false;
},
set: function (value) {
var selected = [];
if (value) {
this.users.forEach(function (user) {
selected.push(user.id);
});
}
this.selected = selected;
}
}
}
非常感谢任何帮助。谢谢:))