vue.js

did you register the component correctly? For recursive components, make sure to provide the "name" option


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?


Solution

  • 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.