强烈建议是按需引入,这样不占太多空间
步骤:
1.安装Vant:npm i vant -S
2.安装babel 插件:npm i babel-plugin-import -D
3.在.babelrc 中添加配置(如果你的项目没有这个文件,就直接跳到步骤4,忽略此步)
"plugins": [ ["import", {
"libraryName": "vant",
"libraryDirectory": "es",
"style": true
}],"transform-vue-jsx", "transform-runtime"]
4.在babel.config.js中配置
module.exports = {
presets: ['@vue/cli-plugin-babel/preset'],
plugins: [
[
'import',
{
libraryName: 'vant',
libraryDirectory: 'es',
style: true,
},
'vant',
],
],
};
5.在页面中引入即可
import Vue from "vue";
import { CountDown } from "vant";
Vue.use(CountDown);