Files
estate/src/utils/rem.ts
2026-04-06 14:45:50 +08:00

13 lines
314 B
TypeScript

// 设计稿 1920px
const baseWidth = 1920;
const baseFontSize = 16;
function setRem() {
const scale = document.documentElement.clientWidth / baseWidth;
const fontSize = baseFontSize * scale;
document.documentElement.style.fontSize = fontSize + 'px';
}
window.addEventListener('resize', setRem);
setRem();