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: {
|
methods: {
|
||||||
|
// @exposed-api
|
||||||
toggleAll(checked) {
|
toggleAll(checked) {
|
||||||
this.children.forEach(item => {
|
if (checked === false) {
|
||||||
item.toggle(checked);
|
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