Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
5637588f
Commit
5637588f
authored
Jul 02, 2021
by
无木
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(demo): fix async tree demo, fixed: #823
parent
5a20df45
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
12 deletions
+24
-12
index.vue
src/views/demo/tree/index.vue
+24
-12
No files found.
src/views/demo/tree/index.vue
View file @
5637588f
...
@@ -27,19 +27,26 @@
...
@@ -27,19 +27,26 @@
/>
/>
</div>
</div>
<div
class=
"flex"
>
<div
class=
"flex"
>
<BasicTree
title=
"异步树"
:treeData=
"tree"
class=
"w-1/3"
:load-data=
"onLoadData"
/>
<BasicTree
title=
"异步树"
ref=
"asyncTreeRef"
:treeData=
"tree"
class=
"w-1/3"
:load-data=
"onLoadData"
/>
</div>
</div>
</PageWrapper>
</PageWrapper>
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
{
defineComponent
,
ref
}
from
'
vue
'
;
import
{
defineComponent
,
ref
,
unref
}
from
'
vue
'
;
import
{
BasicTree
}
from
'
/@/components/Tree/index
'
;
import
{
BasicTree
,
TreeActionType
}
from
'
/@/components/Tree/index
'
;
import
{
treeData
}
from
'
./data
'
;
import
{
treeData
}
from
'
./data
'
;
import
{
PageWrapper
}
from
'
/@/components/Page
'
;
import
{
PageWrapper
}
from
'
/@/components/Page
'
;
export
default
defineComponent
({
export
default
defineComponent
({
components
:
{
BasicTree
,
PageWrapper
},
components
:
{
BasicTree
,
PageWrapper
},
setup
()
{
setup
()
{
const
asyncTreeRef
=
ref
<
Nullable
<
TreeActionType
>>
(
null
);
function
handleCheck
(
checkedKeys
,
e
)
{
function
handleCheck
(
checkedKeys
,
e
)
{
console
.
log
(
'
onChecked
'
,
checkedKeys
,
e
);
console
.
log
(
'
onChecked
'
,
checkedKeys
,
e
);
}
}
...
@@ -57,20 +64,25 @@
...
@@ -57,20 +64,25 @@
return
;
return
;
}
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
tree
.
value
.
forEach
((
v
)
=>
{
const
asyncTreeAction
:
TreeActionType
|
null
=
unref
(
asyncTreeRef
);
if
(
v
.
key
===
treeNode
.
eventKey
)
{
if
(
asyncTreeAction
)
{
v
.
c
hildren
=
[
const
nodeC
hildren
=
[
{
title
:
'
Child Node
'
,
key
:
`
${
treeNode
.
eventKey
}
-0`
},
{
title
:
`Child Node
${
treeNode
.
eventKey
}
-0`
,
key
:
`
${
treeNode
.
eventKey
}
-0`
},
{
title
:
'
Child Node
'
,
key
:
`
${
treeNode
.
eventKey
}
-1`
},
{
title
:
`Child Node
${
treeNode
.
eventKey
}
-1`
,
key
:
`
${
treeNode
.
eventKey
}
-1`
},
];
];
asyncTreeAction
.
updateNodeByKey
(
treeNode
.
eventKey
,
{
children
:
nodeChildren
});
asyncTreeAction
.
setExpandedKeys
([
treeNode
.
eventKey
,
...
asyncTreeAction
.
getExpandedKeys
(),
]);
}
}
});
resolve
();
resolve
();
return
;
return
;
},
1000
);
},
1000
);
});
});
}
}
return
{
treeData
,
handleCheck
,
tree
,
onLoadData
};
return
{
treeData
,
handleCheck
,
tree
,
onLoadData
,
asyncTreeRef
};
},
},
});
});
</
script
>
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment