mirror of
https://github.com/youzan/vant.git
synced 2025-10-17 00:14:18 +00:00
feat(Checkbox): improve toggleAll perf (#5285)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user