react:index.js添加:
const rem = 1920 / document.documentElement.clientWidth;
useEffect(() => {
// 首先先设置html的font-size
(function() {
const styleNode = document.createElement('style');
const w = document.documentElement.clientWidth / 16;
styleNode.innerHTML = `html{font-size:${w}px!important}`;
document.head.appendChild(styleNode);
})();
}, [])
index.less添加:
@rem: 1920/16rem;
margin-bottom: 24/@rem;