-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test recursive and async component (#8)
- Loading branch information
Showing
10 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ dist | |
node_modules | ||
TODOs.md | ||
temp | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script> | ||
import TestRecursive from './recursive/TestRecursive.vue' | ||
import TestAsyncComponent from './async/TestAsyncComponent.vue' | ||
export default { | ||
name: 'TestRecursion', | ||
components: { | ||
TestRecursive, | ||
TestAsyncComponent | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<h2>Vue Component</h2> | ||
|
||
<TestRecursive /> | ||
<TestAsyncComponent /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script> | ||
export default { | ||
components: { | ||
componentA: () => import('./componentA.vue') | ||
}, | ||
beforeCreate() { | ||
this.$options.components.componentB = () => import('./componentB.vue') | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<h3>Async Component</h3> | ||
<componentA /> | ||
<componentB /> | ||
|
||
<pre> | ||
export default { | ||
components: { | ||
componentA: () => import('./componentA.vue') | ||
}, | ||
beforeCreate() { | ||
this.$options.components.componentB = () => import('./componentB.vue') | ||
} | ||
} | ||
</pre> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<p class="async-component-a">This is componentA</p> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<p class="async-component-b">This is componentB</p> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script> | ||
import TestRecursiveTree from './TestRecursiveTree.vue' | ||
import treedata from './treedata.json' | ||
export default { | ||
name: 'TestRecursion', | ||
components: { | ||
TestRecursiveTree | ||
}, | ||
data() { | ||
return { | ||
treedata: treedata | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<h3>Recursive Component</h3> | ||
<TestRecursiveTree :treedata="treedata"></TestRecursiveTree> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script> | ||
export default { | ||
name: 'TestRecursiveTree', | ||
props: ['treedata'], | ||
methods: { | ||
isEmpty(data) { | ||
return !data || !data.length | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="test-recursive-tree"> | ||
<div class="test-recursive-item" v-for="item in treedata" :key="item.label"> | ||
<h5>{{ item.label }}</h5> | ||
|
||
<TestRecursiveTree | ||
v-if="!isEmpty(item.children)" | ||
:treedata="item.children" | ||
> | ||
</TestRecursiveTree> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.test-recursive-item { | ||
padding-left: 10px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"label": "name-1", | ||
"children": [ | ||
{ | ||
"label": "name-1-1", | ||
"children": [ | ||
{ | ||
"label": "name-1-1-1" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters