个人博客:zheng-zhihan.gitee.io
1.创建vant-import.js,进行局部引用
import Vue from 'vue'
import {
Button, // 引入要使用的组件
Search
} from 'vant'
Vue.use(Button)
Vue.use(Search)
2.配置bable.config.js
// vant 局部引入
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
plugins: [
['import', {
libraryName: 'vant',
libraryDirectory: 'es',
style: true
}, 'vant']
]
}
3.在需要使用时直接使用
*注意点:如果进行的rem适配,要在pxtorem中排除掉vant