强烈建议是按需引入,这样不占太多空间

步骤:

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);

 

相关文章:

  • 2022-12-23
  • 2021-05-06
  • 2022-02-27
  • 2022-12-23
  • 2023-04-03
  • 2021-09-14
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案