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?
For those looking for an answer and the others haven't worked, this might:
If you're using a component within a component (e.g. something like this in the Vue DOM):
Here the issue is that
MyComponent
is both the parent and child of itself. This throws Vue into a loop, with each component depending on the other.There's a few solutions to this:
1. Globally register
MyComponent
vue.component("MyComponent", MyComponent)
2. Using
beforeCreate
3. Move the
import
into a lambda function within thecomponents
objectMore info: Vue.js Official Docs — Handling Edge Cases: Circular References Between Components
Note: if you choose method's 2 or 3, in my instance I had to use this method in both the parent and child components to stop this issue arising.
One of the mistakes is setting
components
as array instead of object!This is WRONG:
This is CORRECT:
For recursive components that are not registered globally, it is essential to use not 'any name', but the EXACTLY same name as your component.
Let me give an example:
I had this error and discovered the issue was because the name of the component was identical to the name of a prop.
I was using file components. I changed the Control.vue to InputControl.vue and this warning disappeared.
Since you have applied different name for the components:
You also need to have same name while you export: (Check to name in your Tabpane component)
From the error, what I can say is you have not defined the
name
in your componentTabpane
. Make sure to verify thename
and it should work fine with no error.Make sure that the following are taken care of:
Your import statement & it's path,
Your component TagName you gave in the components {....} block,
Your block name should be components in lower case.
Hope it will solve the issue.