Merge pull request #6211 from msidolphin/fix/#6209
fix: 解决了checkbox-group多层嵌套数据相互干扰的问题
This commit is contained in:
commit
56ed584231
2 changed files with 11 additions and 4 deletions
|
@ -49,7 +49,7 @@
|
|||
},
|
||||
methods: {
|
||||
updateModel (update) {
|
||||
this.childrens = findComponentsDownward(this, 'Checkbox');
|
||||
this.childrens = findComponentsDownward(this, 'Checkbox', 'CheckboxGroup');
|
||||
if (this.childrens) {
|
||||
const { value } = this;
|
||||
this.childrens.forEach(child => {
|
||||
|
|
|
@ -212,11 +212,18 @@ export function findComponentDownward (context, componentName) {
|
|||
}
|
||||
|
||||
// Find components downward
|
||||
export function findComponentsDownward (context, componentName) {
|
||||
export function findComponentsDownward (context, componentName, ignoreComponentNames = []) {
|
||||
if (!Array.isArray(ignoreComponentNames)) {
|
||||
ignoreComponentNames = [ignoreComponentNames]
|
||||
}
|
||||
return context.$children.reduce((components, child) => {
|
||||
if (child.$options.name === componentName) components.push(child);
|
||||
if (ignoreComponentNames.indexOf(child.$options.name) < 0) {
|
||||
const foundChilds = findComponentsDownward(child, componentName);
|
||||
return components.concat(foundChilds);
|
||||
} else {
|
||||
return components
|
||||
}
|
||||
}, []);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue