Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions demo/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export default {
nodechekced (node, v) {
alert('that a node-check envent ...' + node.title + v)
},
// tpl (node, ctx, parent, index, props) {
tpl (...args) {
// console.dir(args)
const {0: node, 2:parent} = args
let {0: node, 2: parent, 3: index} = args
let titleClass = node.selected ? 'node-title node-selected' : 'node-title'
if (node.searched) titleClass += ' node-searched'
return <span>
Expand All @@ -77,29 +77,26 @@ export default {
this.$refs.tree1.nodeSelected(node)
}}></span>
<button class="treebtn2" onClick={() => this.asyncLoad1(node)}>async</button>
<button class="treebtn3" onClick={() => this.$refs.tree1.delNode(parent, node)}>delete</button>
<button class="treebtn3" onClick={() => this.$refs.tree1.delNode(node, parent, index)}>delete</button>
</span>
},
async asyncLoad1 (node) {
this.$set(node, 'loading', true)
let pro = new Promise((resolve, reject) => {
let pro = new Promise(resolve => {
setTimeout(resolve, 2000, ['async node1', 'async node2'])
})
this.$refs.tree1.addNodes(node, await pro)
this.$set(node, 'loading', false)
},
async asyncLoad2 (node) {
this.$set(node, 'loading', true)
let pro = await new Promise((resolve, reject) => {
let pro = await new Promise(resolve => {
setTimeout(resolve, 2000, [{title: 'test1', async: true}, {title: 'test2', async: true}, {title: 'test3'}])
})

pro.forEach((el) => {
if (!node.hasOwnProperty('children')) {
this.$set(node, 'children', [])
}
node.children.push(el)
})
if (!node.hasOwnProperty('children')) {
this.$set(node, 'children', [])
}
node.children.push(...pro)
this.$set(node, 'loading', false)
},
search () {
Expand Down