rem.ts 573 Bytes
/*
 * @Description: 
 * @Author: huyue
 * @Date: 2022-10-10 10:59:01
 * @LastEditors: huyue
 * @LastEditTime: 2022-10-25 18:08:24
 */
let baseSize = 37.5
function setRem() {
  const scale = document.documentElement.clientWidth / 750
  document.documentElement.style.fontSize = baseSize * Math.min(scale, 3) + 'px'
}
function throttle(func, wait) {
  let timeout
  return function () {
    if (!timeout) {
      timeout = setTimeout(function () {
        func()
        timeout = null
      }, wait)
    }
  }
}
setRem()
window.onresize = throttle(() => {
  setRem()
}, 500)