revert: tree watch logic
parent
61b5bfa0f6
commit
1abc37403d
|
@ -27,6 +27,16 @@ import {
|
||||||
* other props can pass with context for future refactor.
|
* other props can pass with context for future refactor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function getWatch(keys = []) {
|
||||||
|
const watch = {};
|
||||||
|
keys.forEach(k => {
|
||||||
|
watch[k] = function() {
|
||||||
|
this.needSyncKeys[k] = true;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return watch;
|
||||||
|
}
|
||||||
|
|
||||||
const Tree = {
|
const Tree = {
|
||||||
name: 'Tree',
|
name: 'Tree',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
|
@ -129,17 +139,19 @@ const Tree = {
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
// ...getWatch([
|
// watch 引用类型的改变
|
||||||
// 'treeData',
|
...getWatch([
|
||||||
// 'children',
|
'treeData',
|
||||||
// 'expandedKeys',
|
'children',
|
||||||
// 'autoExpandParent',
|
'expandedKeys',
|
||||||
// 'selectedKeys',
|
'autoExpandParent',
|
||||||
// 'checkedKeys',
|
'selectedKeys',
|
||||||
// 'loadedKeys',
|
'checkedKeys',
|
||||||
// ]),
|
'loadedKeys',
|
||||||
|
]),
|
||||||
__propsSymbol__() {
|
__propsSymbol__() {
|
||||||
this.setState(this.getDerivedState(getOptionProps(this), this.$data));
|
this.setState(this.getDerivedState(getOptionProps(this), this.$data));
|
||||||
|
this.needSyncKeys = {};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -149,8 +161,9 @@ const Tree = {
|
||||||
const newState = {
|
const newState = {
|
||||||
_prevProps: { ...props },
|
_prevProps: { ...props },
|
||||||
};
|
};
|
||||||
|
const self = this;
|
||||||
function needSync(name) {
|
function needSync(name) {
|
||||||
return (!_prevProps && name in props) || (_prevProps && _prevProps[name] !== props[name]);
|
return (!_prevProps && name in props) || (_prevProps && self.needSyncKeys[name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Tree Node ==================
|
// ================== Tree Node ==================
|
||||||
|
|
Loading…
Reference in New Issue