移动端 postcss-pxtorem插件使用

yarn add postcss-pxtorem

复制代码
vue.config.js配置  
 loaderOptions: {
    postcss: {
      plugins: [
        require('postcss-pxtorem')({
          rootValue: 50, // vant用的是375设计
          propList: ['*'],
        })
      ]
    }
  }
 
复制代码
1
2
3
4
5
6
7
8
9
10
11
<!-- 设置 rem 大小:1rem = 100px,使用 750px 设计稿 --><br>  这里需要在public文件下的index.html 添加配置
    <script>
      ;(function() {
        var f = function() {
          document.documentElement.style.fontSize =
            document.documentElement.clientWidth / 7.5 + 'px'
        }
        f()
        window.addEventListener && window.addEventListener('resize', f, false)
      })()
    </script>

  

posted @   Alitar  阅读(455)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示