vue 2.0 Configuration and vue 3.0 rem

vue 2.0 Configuration rem  

First install postcss-px2rem (Baidu can)  https://www.jianshu.com/p/e6476bbc2131

    npm install postcss-px2rem

Locate the file build / vue-loader.config.js add

const px2rem = require('postcss-px2rem')
postcss: function() {
    return [px2rem({remUnit: 75})];
}

 

 

 

 

In the configuration file index.html

  <script>
    document.getElementsByTagName('html')[0].style.fontSize = (document.documentElement.clientWidth || document.body
      .clientWidth) / 10 + 'px';
    window.addEventListener("resize", () => {
      document.getElementsByTagName('html')[0].style.fontSize = (document.documentElement.clientWidth || document
        .body.clientWidth) / 10 + 'px';
    });
  </script>

 

 

Configuration vue 3.0 REM (Baidu can)

The chiefs of  https://www.jianshu.com/p/94902796f2ad

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/TreeCTJ/p/11823024.html