vue报错Unknown custom element

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vue报错Unknown custom element相关的知识,希望对你有一定的参考价值。

参考技术A [Vue warn]: Unknown custom element: <input-cdc-center> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

1,新建组件文件:

input-cdc-center.vue

2,在使用组件的文件中引入组件:

import from '../screeningRecord/input-cdc-center'

3,添加到组件中:

components:



4,使用:

<input-cdc-center></input-cdc-center>

红色部分需要用驼峰写法(首字母大写)

[Vue warn]: Unknown custom element: did you register the component correctly?

前言

[Vue warn]: Unknown custom element:  did you register the component correctly? For recursive components, make sure to provide the "name" option.

问题原因是:使用了相关组件,但没有引入

解决思路

首先找出引起报错的相关代码,查看有没有使用类似组件,例如使用了 radio-groupradio组件,但是没有引入,这时候就会出现上面的错误

 <el-form-item label="状态:">
      <el-radio-group v-model="formData.status">
            <el-radio :key="item.value"
            :label="item.value"
            v-for="item in statusOptions" >{{item.label}}</el-radio>
      </el-radio-group>
</el-form-item>

在项目目录中找到 main.js,然后 import {} from引入相关组件,再 Vue.use()使用即可,例如:

import {
    Radio,
    RadioGroup,
} from \'element-ui\';

Vue.use(Radio);
Vue.use(RadioGroup);

这样就完成了组件的全局引入

以上是关于vue报错Unknown custom element的主要内容,如果未能解决你的问题,请参考以下文章

vue报错Unknown custom element:<el-descriptions> did you register the component

[Vue warn]: Unknown custom element: <todo-item> - did you register the component correctly?

[Vue warn]: Unknown custom element: did you register the component correctly?

Vue入门之旅:一报错 Unknown ... make sure to provide the "name" option及error compiling template(示例

记录:Unknown custom element: [v-table] - did you register the component correctly...报错亲测有效

前端vue Unknown custom element: xxxx did you register the component correctly