vant按需自動引入使用標簽時報錯

Unknown custom element: <van-tag> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

這個是報的錯,說我沒注冊我:?????
搞半天不知道怎么弄,翻閱了一下官網(wǎng),我采用的是推薦使用的按需自動引入
先貼上來:

// 在.babelrc 中添加配置
// 注意:webpack 1 無需設(shè)置 libraryDirectory
{
  "plugins": [
    ["import", {
      "libraryName": "vant",
      "libraryDirectory": "es",
      "style": true
    }]
  ]
}

// 對于使用 babel7 的用戶,可以在 babel.config.js 中配置
module.exports = {
  plugins: [
    ['import', {
      libraryName: 'vant',
      libraryDirectory: 'es',
      style: true
    }, 'vant']
  ]
};

本來以為這樣就可以萬事大吉了,然鵝并不是.我想使用標簽組件的時候
我在template中直接復制

<van-tag v-if="show" closeable size="medium" type="primary" @close="close">
  標簽
</van-tag>

竟然報錯了......無語子
后來發(fā)現(xiàn)必須要在下面組件中寫這樣一個

 import {
        testLogin
    } from '@/request/api.js'
    import {
        Tag
    } from 'vant';
    export default {
        name: 'index',
        components: {
            [Tag.name]: Tag
        },
}

才不報錯了....踩坑+1

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容