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?
To fix the 'did you register the component correctly? For recursive components, make sure to provide the "name" option' error in Vue. js, we should register the components we reference in our template. to register the i-tabs and i-tab-pane component where Tabs and TabPane are components.
You could have just one Product Component that you could render on different pages as opposed to repeating the code for the Product Component on every page it's needed. A Vue component is considered recursive if it references itself within its own template.
When we want to globally register a component in Vue, we need to do it in this file. All you have to do is import your component, as you usually would, and then register it using app. component . import { createApp } from 'vue' import App from './App.
Vue. js is a progressive framework for JavaScript used to build web interfaces and one-page applications. Not just for web interfaces, Vue. js is also used both for desktop and mobile app development with Electron framework.
If you're using a component within a component (e.g. something like this in the Vue DOM):
App MyComponent ADifferentComponent MyComponent
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:
MyComponent
vue.component("MyComponent", MyComponent)
beforeCreate
beforeCreate: function () { this.$options.components.MyComponent = require('./MyComponent.vue').default }
import
into a lambda function within the components
objectcomponents: { MyComponent: () => import('./MyComponent.vue') }
My preference is the third option, it's the simplest tweak and fixes the issue in my case.
More 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With