fix dom rendering problems
This commit is contained in:
parent
b31aab71d2
commit
da76a837e3
3 changed files with 28 additions and 22 deletions
|
@ -34,11 +34,11 @@
|
||||||
size: 'small'
|
size: 'small'
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
click: () => {
|
click: ({target}) => {
|
||||||
this.cc();
|
this.logger(target.textContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, '我是按钮')
|
}, 'I\'m a button!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleAdd () {
|
handleAdd () {
|
||||||
|
@ -55,18 +55,20 @@
|
||||||
title: 'test name',
|
title: 'test name',
|
||||||
checked: true
|
checked: true
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
},
|
},
|
||||||
handleUpdate () {
|
handleUpdate () {
|
||||||
this.$set(this.baseData[0].children[0].children[1], 'checked', true);
|
const child = this.baseData[0].children[0].children[1];
|
||||||
|
// console.log(JSON.stringify(this.baseData), '\n', JSON.stringify(child));
|
||||||
|
if (!child) return this.$Message.error('Node is async and is not loaded yet');
|
||||||
|
else this.$set(child, 'checked', true);
|
||||||
},
|
},
|
||||||
cc () {
|
logger (txt) {
|
||||||
console.log(99)
|
console.log(txt);
|
||||||
},
|
},
|
||||||
loadData (item, callback) {
|
loadData (item, callback) {
|
||||||
item.loading = true;
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
item.children = [
|
callback([
|
||||||
{
|
{
|
||||||
title: 'children-1',
|
title: 'children-1',
|
||||||
loading: false,
|
loading: false,
|
||||||
|
@ -77,11 +79,9 @@
|
||||||
loading: false,
|
loading: false,
|
||||||
children: []
|
children: []
|
||||||
}
|
}
|
||||||
];
|
]);
|
||||||
item.loading = false;
|
|
||||||
callback();
|
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
<span v-else :class="titleClasses" v-html="data.title" @click="handleSelect"></span>
|
<span v-else :class="titleClasses" v-html="data.title" @click="handleSelect"></span>
|
||||||
<Tree-node
|
<Tree-node
|
||||||
v-if="data.expand"
|
v-if="data.expand"
|
||||||
v-for="item in data.children"
|
v-for="(item, i) in data.children"
|
||||||
:key="item.nodeKey"
|
:key="i"
|
||||||
:data="item"
|
:data="item"
|
||||||
:multiple="multiple"
|
:multiple="multiple"
|
||||||
:show-checkbox="showCheckbox">
|
:show-checkbox="showCheckbox">
|
||||||
|
@ -60,6 +60,9 @@
|
||||||
return {
|
return {
|
||||||
prefixCls: prefixCls
|
prefixCls: prefixCls
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
classes () {
|
classes () {
|
||||||
|
@ -104,12 +107,15 @@
|
||||||
if (item.disabled) return;
|
if (item.disabled) return;
|
||||||
|
|
||||||
// async loading
|
// async loading
|
||||||
if (item.loading !== undefined && !item.children.length) {
|
if (item.children.length === 0) {
|
||||||
const tree = findComponentUpward(this, 'Tree');
|
const tree = findComponentUpward(this, 'Tree');
|
||||||
if (tree && tree.loadData) {
|
if (tree && tree.loadData) {
|
||||||
tree.loadData(item, () => {
|
this.$set(this.data, 'loading', true);
|
||||||
if (item.children.length) {
|
tree.loadData(item, children => {
|
||||||
this.handleExpand(item);
|
this.$set(this.data, 'loading', false);
|
||||||
|
if (children.length) {
|
||||||
|
this.$set(this.data, 'children', children);
|
||||||
|
this.$nextTick(() => this.handleExpand());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="prefixCls">
|
<div :class="prefixCls">
|
||||||
<Tree-node
|
<Tree-node
|
||||||
v-for="item in stateTree"
|
v-for="(item, i) in stateTree"
|
||||||
:key="item.nodeKey"
|
:key="i"
|
||||||
:data="item"
|
:data="item"
|
||||||
visible
|
visible
|
||||||
:multiple="multiple"
|
:multiple="multiple"
|
||||||
|
|
Loading…
Add table
Reference in a new issue