[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