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
9298b3c9
Commit
9298b3c9
authored
Jun 23, 2021
by
JinMao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add Tree LoadData demo
parent
8d22231a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
2 deletions
+32
-2
index.vue
src/views/demo/tree/index.vue
+32
-2
No files found.
src/views/demo/tree/index.vue
View file @
9298b3c9
...
...
@@ -26,10 +26,13 @@
class=
"w-1/3"
/>
</div>
<div
class=
"flex"
>
<BasicTree
title=
"异步树"
:treeData=
"tree"
class=
"w-1/3"
:load-data=
"onLoadData"
/>
</div>
</PageWrapper>
</
template
>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
defineComponent
,
ref
}
from
'
vue
'
;
import
{
BasicTree
}
from
'
/@/components/Tree/index
'
;
import
{
treeData
}
from
'
./data
'
;
import
{
PageWrapper
}
from
'
/@/components/Page
'
;
...
...
@@ -40,7 +43,34 @@
function
handleCheck
(
checkedKeys
,
e
)
{
console
.
log
(
'
onChecked
'
,
checkedKeys
,
e
);
}
return
{
treeData
,
handleCheck
};
const
tree
=
ref
([
{
title
:
'
parent
'
,
key
:
'
0-0
'
,
},
]);
function
onLoadData
(
treeNode
)
{
return
new
Promise
((
resolve
:
(
value
?:
unknown
)
=>
void
)
=>
{
if
(
!
treeNode
.
children
)
{
resolve
();
return
;
}
setTimeout
(()
=>
{
tree
.
value
.
forEach
((
v
)
=>
{
if
(
v
.
key
===
treeNode
.
eventKey
)
{
v
.
children
=
[
{
title
:
'
Child Node
'
,
key
:
`
${
treeNode
.
eventKey
}
-0`
},
{
title
:
'
Child Node
'
,
key
:
`
${
treeNode
.
eventKey
}
-1`
},
];
}
});
resolve
();
return
;
},
1000
);
});
}
return
{
treeData
,
handleCheck
,
tree
,
onLoadData
};
},
});
</
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