mirror of https://github.com/ElemeFE/element
Fix Tree Bug: set data does not work
parent
8af8c8b8fe
commit
cd7156cb03
|
@ -28,7 +28,7 @@ const reInitChecked = function(node) {
|
||||||
|
|
||||||
const getPropertyFromData = function(node, prop) {
|
const getPropertyFromData = function(node, prop) {
|
||||||
const props = node.props;
|
const props = node.props;
|
||||||
const data = node.data;
|
const data = node.data || {};
|
||||||
const config = props[prop];
|
const config = props[prop];
|
||||||
|
|
||||||
if (typeof config === 'function') {
|
if (typeof config === 'function') {
|
||||||
|
@ -69,6 +69,12 @@ export default class Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lazy !== true && this.data) {
|
if (this.lazy !== true && this.data) {
|
||||||
|
this.setData(this.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setData(data) {
|
||||||
|
this.data = data;
|
||||||
let children;
|
let children;
|
||||||
if (this.level === -1 && this.data instanceof Array) {
|
if (this.level === -1 && this.data instanceof Array) {
|
||||||
children = this.data;
|
children = this.data;
|
||||||
|
@ -87,7 +93,6 @@ export default class Node {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
get label() {
|
get label() {
|
||||||
return getPropertyFromData(this, 'label');
|
return getPropertyFromData(this, 'label');
|
||||||
|
|
|
@ -68,6 +68,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
data(newVal) {
|
||||||
|
this.tree.root.setData(newVal);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
getCheckedNodes(leafOnly) {
|
getCheckedNodes(leafOnly) {
|
||||||
return this.tree.getCheckedNodes(leafOnly);
|
return this.tree.getCheckedNodes(leafOnly);
|
||||||
|
|
Loading…
Reference in New Issue