官网
1.基本使用
1.安装Vant UI npm i vant -S2.main.js 导入MintUI,并注册到Vue import Vue from 'vue' //全局引入Vant UI的样式以及组件库 import 'vant/lib/index.css'; import Vant from 'vant'; Vue.use(Vant); var vm = new Vue({ el: '#app', data: { msg: '123' }, render:e=>e(app) })3.app.vue<template> <div> <van-button type="default" @click="showPopup">默认按钮</van-button> <van-button type="primary">主要按钮</van-button> <van-button type="info">信息按钮</van-button> <van-button type="warning">警告按钮</van-button> <van-button type="danger">危险按钮</van-button> <van-popup v-model="show">内容</van-popup> </div></template>
2.按需导入
//1.安装babel-plugin-import插件 npm i babel-plugin-import -D//2.修改babel的配置文件 { "presets": [ "env", "stage-0" ], "plugins": [ "transform-runtime", [ "import", { "libraryName": "vant", "libraryDirectory": "es", "style": true } ] ]} //3.修改main.js//按需加载 用到什么就去引入什么import { Button,Popup,Form,Field } from 'vant';Vue.use(Button);Vue.use(Popup);Vue.use(Form);Vue.use(Field);
babel版本配置错误解决方案