安装vue2脚手架:vue i -g @vue/cli
检查脚手架是否安装成功:vue --version
使用脚手架创建一个项目:vue create 项目名
运行:npm run serve
vue2项目使用的是vue-cli+vant+less+axios开发
①、安装amfe-flesible:会自动设置html的font-size大小,为 屏幕宽度/10。
npm i amfe-flexible --save
②、安装postcss-pxtorem,会自动将css中的px自动转成rem单位。
npm i postcss-pxtorem --save -dev
③、在项目根目录下新建postcss.config.js
module.exports = {
plugins: [
require('postcss-pxtorem')({
rootValue: 37.5, //根据设计稿自行设置//代表1rem = 75px 比如页面宽750px,最终页面会换算成 10rem
propList: ['*'],
exclude: /node_modules/i //这里表示不处理node_modules文件夹下的内容
})
]
}
④、在src的assets下新建文件css-新建reset.css
@charset "utf-8";html{background-color:#fff;color:#0