新的解决方案:
step1:
cnpm install vant --save-dev
step2:
cnpm install babel-plugin-import --save-dev
step3: babel.config.js 添加
module.exports = {
presets: ["@vue/cli-plugin-babel/preset"],
plugins: [['import', {
libraryName: 'vant',
libraryDirectory: 'es',
style: true
}, 'vant']]
};
step4: main.js 添加
import { Button } from 'vant'
Vue.use(Button)
step5: App.vue
<template>
<div>
<h1>关于</h1>
<van-button type="primary">主要按钮</van-button>
<van-button type="info">信息按钮</van-button>
<van-button type="default">默认按钮</van-button>
<van-button type="warning">警告按钮</van-button>
<van-button type="danger">危险按钮</van-button>
</div>
</template>
step6:
npm run serve
add:
全局新增 main.js
import Vue from "vue";
import App from "./App.vue";
import router from './router'
// main.js
import Vant from 'vant'
import 'vant/lib/index.css';
Vue.use(Vant)
Vue.config.productionTip = false;
new Vue({
router,
render: (h) => h(App),
}).$mount("#app");
it is work!
end