Skip to content

Commit

Permalink
Merge pull request #6211 from msidolphin/fix/#6209
Browse files Browse the repository at this point in the history
fix: 解决了checkbox-group多层嵌套数据相互干扰的问题
  • Loading branch information
DebugIsFalse committed Sep 4, 2019
2 parents 9199cee + 9e694e9 commit 56ed584
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/checkbox/checkbox-group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
13 changes: 10 additions & 3 deletions src/utils/assist.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
const foundChilds = findComponentsDownward(child, componentName);
return components.concat(foundChilds);
if (ignoreComponentNames.indexOf(child.$options.name) < 0) {
const foundChilds = findComponentsDownward(child, componentName);
return components.concat(foundChilds);
} else {
return components
}
}, []);
}

Expand Down

0 comments on commit 56ed584

Please sign in to comment.