# npm 安装
npm i vant -S
# main 引入 Vant
在 main.js 中写入以下内容:
import Vue from 'vue'
import App from './App'
import router from './router'
import Vant from 'vant';
import 'vant/lib/index.css';
Vue.use(Vant);
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
});
# cnd 引入 Vant
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>chenbz</title>
<!-- 引入 vant 样式 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.1/lib/index.css">
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
<!-- 引入 vant 组件 -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vant@2.1/lib/vant.min.js"></script>
</body>
</html>
根目录下build/webpack.base.config.js中添加externals
......
module.exports = {
......,
externals: {
'vue' : 'Vue',
'vant' : 'vant',
}
};