rem

在vue的index.html中使用

<script>
    fnResize();
    window.onresize = function () {
      fnResize();
    }
    function fnResize() {
      var deviceWidth = document.documentElement.clientWidth || window.innerWidth;
      if (deviceWidth >= 750) {
        deviceWidth = 750;
      }
      if (deviceWidth <= 320) {
        deviceWidth = 320;
      }
      document.documentElement.style.fontSize = (deviceWidth / 7.5) + 'px';
    }
  </script>
原文地址:https://www.cnblogs.com/xhrr/p/12027262.html