Vant UI + Vue + Cli3.0 + Rem移动端项目搭建
1. 创建vue
项目
- 创建项目
复制代码
1
2vue create vant-demo
- 引入
less
(通过vue ui
可视化页面安装依赖插件)
复制代码
1
2vue ui
2. 引入vant ui
复制代码
1
2npm i vant -S
3. 按需引入
3-1. 安装babel
插件
复制代码
1
2npm i babel-plugin-import -D
温馨提示:在使用自动按需引入的时候,在使用相关组件的时候,需要在maim.js
中一一引入,如下:
复制代码
1
2
3
4
5
6import { Button,Cell, CellGroup } from 'vant'; Vue.use(Cell); Vue.use(CellGroup) Vue.use(Button);
3-2. 配置babel.config.js
复制代码
1
2
3
4
5
6
7
8
9
10module.exports = { plugins: [ ['import', { libraryName: 'vant', libraryDirectory: 'es', style: true }, 'vant'] ] };
4. Rem
适配
4-1. 安装postcss-pxtorem
与amfe-flexible
复制代码
1
2
3npm install postcss-pxtorem --save-dev npm i -S amfe-flexible
4-2. 配置vue.config.js
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19module.exports = { lintOnSave: true, css: { loaderOptions: { postcss: { plugins: [ require('postcss-pxtorem')({ rootValue : 37.5, // 换算的基数 propList : ['*'], }), require('autoprefixer')({ browsers: ['Android >= 4.0', 'iOS >= 8'] }) ] } } }, }
4-3. 配置main.js
复制代码
1
2import 'amfe-flexible/index.js'
5. 配置完成
最后
以上就是笑点低嚓茶最近收集整理的关于Vant UI + Vue + Cli3.0 + Rem移动端项目搭建的全部内容,更多相关Vant内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复