您是否正确注册了组件?对于递归组件,请确保提供“名称";选项 [英] did you register the component correctly? For recursive components, make sure to provide the "name" option
问题描述
我配置了'i-tab-pane': Tabpane
但是报错,代码如下:
<div class="page-common"><i-tabs><i-tab-pane label="wx">内容</i-tab-pane></i-tabs>
</模板><脚本>进口 {标签,大板来自'iview'导出默认{名称:数据中心",数据(){返回 {msg: '你好 vue'}},成分: {'i-tabs':标签,'i-tab-pane': Tabpane}}
错误回溯:
[Vue warn]:未知的自定义元素:<i-tab-pane>- 您是否正确注册了组件?对于递归组件,请确保提供名称"选项.在发现---><数据中心>在 src/views/dc/data-center.vue<索引>在 src/views/index.vue<应用程序>在 src/app.vue
<小时>
我已经尝试在main.js
中进行全局配置:
Vue.component("Tabpane", Tabpane);
但是还是不行.如何解决这个问题?
由于您为组件应用了不同的名称:
组件:{'i-tabs':标签,'i-tab-pane': Tabpane}
导出时还需要具有相同的名称:(检查 Tabpane 组件中的名称)
name: 'Tabpane'
从错误中,我可以说您没有在组件 Tabpane
中定义 name
.确保验证 name
,它应该可以正常工作,没有错误.
I configured 'i-tab-pane': Tabpane
but report error,the code is bellow:
<template>
<div class="page-common">
<i-tabs>
<i-tab-pane label="wx">
content
</i-tab-pane>
</i-tabs>
</div>
</template>
<script>
import {
Tabs,
Tabpane
} from 'iview'
export default{
name:"data-center",
data(){
return {msg: 'hello vue'}
},
components: {
'i-tabs' : Tabs,
'i-tab-pane': Tabpane
}
}
</script>
Error traceback:
[Vue warn]: Unknown custom element: <i-tab-pane> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
found in
---> <DataCenter> at src/views/dc/data-center.vue
<Index> at src/views/index.vue
<App> at src/app.vue
I have tried in the main.js
to global configuration:
Vue.component("Tabpane", Tabpane);
but still do not work. How to resolve this issue?
Since you have applied different name for the components:
components: {
'i-tabs' : Tabs,
'i-tab-pane': Tabpane
}
You also need to have same name while you export: (Check to name in your Tabpane component)
name: 'Tabpane'
From the error, what I can say is you have not defined the name
in your component Tabpane
. Make sure to verify the name
and it should work fine with no error.
这篇关于您是否正确注册了组件?对于递归组件,请确保提供“名称";选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!