[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the “name” option.
![在是用Vant的優惠券組件的時候出現了該錯誤]()
在使用Vant的優惠券組件的時候出現了該錯誤
我按照官方文檔
- npm i vant -S安裝
- npm i babel-plugin-import -D 安裝插件
- 配置.babelrc
- 在main.js文件中按需引入組件
import { CouponCell, CouponList } from 'vant'; Vue.use(CouponCell).use(CouponList);
然後它就提示我van-popup組件沒有註冊,原來是這個組件依賴於popup這個組件,官方文檔卻省略了這一步。
解決方案:
在main.js引用這個popup組件
import { Popup } from 'vant';
Vue.use(Popup);
所以最終是這樣
import { CouponCell, CouponList } from 'vant';
Vue.use(CouponCell).use(CouponList);
import { Popup } from 'vant';
Vue.use(Popup);
但是這樣組件還是無法正常使用,點擊優惠券列表是無法進行彈出的,它還有個showList報錯
解決方案:
在data return 中定義一個showList:false