12 lines
391 B
TypeScript
12 lines
391 B
TypeScript
function setRootFontSize(): void {
|
|
const baseWidth = 1920 // 设计稿宽度
|
|
const baseFontSize = 16 // 设计稿根字体
|
|
const screenWidth = window.innerWidth
|
|
const fontSize = (screenWidth / baseWidth) * baseFontSize
|
|
document.documentElement.style.fontSize = fontSize + 'px'
|
|
}
|
|
|
|
setRootFontSize()
|
|
window.addEventListener('resize', setRootFontSize)
|
|
|
|
export default setRootFontSize
|