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

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM