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