移动端页面适配(px2rem)

1、安装

引入lib-flexible . 

  安装lib-flexible:  npm i lib-flexible --save

  在项目的入口main.js文件中引入lib-flexible: import 'lib-flexible'

一定不要忘了是在main.js中

2、使用和安装px2rem  

使用postcss-px2rem自动将css中的px转换成rem(真的是大大提升了我们的工作效率,棒棒的,不用自己去瞎算啊)

  安装postcss-px2rem :  npm install postcss-px2rem --save-dev

3. 移除public中index.html中关于viewport的meta标签 好像不移除也没事

根目录下新建vue.config.js,加入配置项 (cli4中好像不移除也没事) 改了设计稿,需要重新启动服务 

module.exports = {

    // devServer: {

    //   proxy: {

    //     '/ajax': {

    //       target: 'http://m.maoyan.com',

    //       // ws: true,

    //       changeOrigin: true

    //     },

    //     '/foo': {

    //       target: '<other_url>'

    //     }

    //   }

    // },

    lintOnSave: false ,



    css: {

        loaderOptions: {

               css: {

                       // options here will be passed to css-loader

               },

         postcss: {

                    // options here will be passed to postcss-loader

                    plugins: [require('postcss-px2rem')({

                              remUnit:75,//设计稿的 十分之一

                              "exclude": /node_modules/i

                    })]

               }

          }

      }

  }

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值