【发布时间】:2022-08-03 17:10:05
【问题描述】:
Vue3中如何使用递归组件?
在 Vue 3 中像普通组件一样使用递归组件会导致错误 Cannot access before initialization
树.vue:
<template>
<Tree v-if=\"hasChildren\" />
</template>
<script lang=\"ts\">
import Tree from \'./Tree.vue\';
export default defineComponent({
components: {
Tree
},
setup() {
const hasChildren = someExitRecursionCondition();
return {
hasChildren
}
}
</script>