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