Ant Design Vue - 使用某些組件直接報錯 “組件未註冊” did you register the component correctly?

前言 

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

該款框架正常配置後,使用 <a-button> 等基礎組件一切正常!

但今天使用<a-transfer> 穿梭框組件,突然控制檯報錯:

VM70088 vue.runtime.esm.js:620 [Vue warn]: Unknown custom element: <a-transfer> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

原因

框架爲了減少編譯支持庫包大小,這些 “報錯組件” 是 按需加入
說白話,就是這些報錯組件需要你自己去手動加入,默認是不加載的。

 解決

一、依次打開項目文件夾 【src】 → 【core】,如下圖所示:

二、找到【core】文件夾下的 lazy_use.js 文件,這是個按需加載的配置文件(每個項目的文件名不同),如下圖所示:

三、加入 “未註冊的組件”,如下圖所示:

組件列表參照官網:https://github.com/vueComponent/ant-design-vue/blob/master/components/index.js

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章