写个js直接家到页面中,使用中直接px就可以。他是根据比例缩放像素。
<script>
const getFontSize = () => {
let designWidth = 375 // 设计稿宽度
document.documentElement.style.fontSize = (window.innerWidth / designWidth) * 100 + "px"
}
getFontSize()
window.onresize = getFontSize
</script>