【发布时间】:2018-07-23 18:07:33
【问题描述】:
我正在尝试制作一个可以调用自身的自定义组件。我不断收到错误
Unknown custom element: <TestRec> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
我已经包含了一个名称选项,如下所示,但这并不能解决问题。
知道它可能是什么吗?
<template>
<div>
<h4>I am a component that can call itself below</h4>
<v-select :items="['TestRec', 'normal']" v-model="comp"></v-select>
<hr />
<component :is="comp"></component>
</div>
</template>
<script>
import TestRec from "./TestRec";
export default {
name: 'New-Test-Rec', //Name tried 'Test-Rec' too. Same result
components: {
TestRec
},
data(){
return {
comp: null
}
}
}
</script>
【问题讨论】:
标签: javascript recursion vue.js vuejs2 components