Merge branch '2.0' of https://github.com/iview/iview into 2.0

This commit is contained in:
mo.duan 2019-09-04 11:17:08 +08:00
commit 88f40c57a6
3 changed files with 13 additions and 4 deletions

View file

@ -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 => {

View file

@ -235,9 +235,11 @@
},
handleLeftCheckedKeysChange (keys) {
this.leftCheckedKeys = keys;
this.handleCheckedKeys();
},
handleRightCheckedKeysChange (keys) {
this.rightCheckedKeys = keys;
this.handleCheckedKeys();
},
handleCheckedKeys () {
const sourceSelectedKeys = this.getValidKeys('left');

View file

@ -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
}
}, []);
}