mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Checkbox): improve toggleAll perf (#5285)
This commit is contained in:
parent
50b4116ca5
commit
9cd06f3b20
@ -24,10 +24,20 @@ export default createComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
// @exposed-api
|
||||
toggleAll(checked) {
|
||||
this.children.forEach(item => {
|
||||
item.toggle(checked);
|
||||
});
|
||||
if (checked === false) {
|
||||
this.$emit('input', []);
|
||||
return;
|
||||
}
|
||||
|
||||
let { children } = this;
|
||||
if (!checked) {
|
||||
children = children.filter(item => !item.checked);
|
||||
}
|
||||
|
||||
const names = children.map(item => item.name);
|
||||
this.$emit('input', names);
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user