let nowClientWidth = document.documentElement.clientWidth; export const nowSize = (px, initWidth = 1920) => { // return val * (nowClientWidth / initWidth); let clientWidth = window.innerWidth || document.body.clientWidth; //屏幕尺寸 if (!clientWidth) { return 0; } let fontSize = clientWidth / 1920; //设计稿尺寸 return px * fontSize; //转换为 rem的布局返回出去 }