一、封装rem.js

(function() {
  function resi() {
    var html = document.querySelector('html')
    var wW = document.body.clientWidth || document.documentElement.clientWidth
    var maxW = 640
    var minW = 320
    if (wW > maxW) wW = maxW
    var ratio = wW / minW
    html.style.fontSize = 50 * ratio + 'px'
  }
  window.addEventListener('DOMContentLoaded', function() {
    var bodys = document.querySelector('body').style
    bodys.opacity = '1'
    bodys.filter = 'alpha(opacity=100)'
    resi()
  })
  window.addEventListener('resize', resi)
})()

二、在vue 的main.js 中加入

import 'assets/js/rem'
Logo

前往低代码交流专区

更多推荐