[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);

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

posted @ 2021-05-13 10:43  牛奔  阅读(2385)  评论(0编辑  收藏  举报