1. Build VUE2.0 project
vue create '项目名'
2. Install the flexible plug-in (adapted to the mobile plug-in)
npm install lib-flexible -S
2.1 Introduce the flexible plugin in main.js
import 'amfe-flexible';
3. Install postcss-pxtorem (convert px to rem)
npm install postcss-pxtorem --save // 默认最新版本
// 安装这个版本 版本过高有可能会出现问题
npm install [email protected] --save
4. Install amfe-flexible
npm install --save amfe-flexible
5. Create a new postcss.config.js, which is at the same level as vue.config.js
module.exports = {
plugins: {
"postcss-pxtorem": {
// 设计稿 375:37.5
// 设计稿:750:75
// Vant 是基于 375
// rootValue根据设计稿宽度除以10进行设置
rootValue: 37.5,
propList: ["*"],
selectorBlackList: ['van'] // 过滤掉VantUI组件
}
}
}
The vue2.0 project uses the vant2 version of the component Vant 2 - Mobile UI Components built on Vue
npm i vant@latest-v2 -S
Introduced in main.js
import Vant from 'vant';
import 'vant/lib/index.css';
Vue.use(Vant);