移动端适配代码
标黄的根据自己项目进行修改(适用于vue)
(function () {
var supportsOrientationChange = 'onorientationchange' in window ? 'orientationchange' : 'resize';
var timeoutId;
function setRem() {
var clientWidth = document.documentElement.clientWidth;
var nowPX = clientWidth / 640 * 100;
document.documentElement.style.fontSize = nowPX + 'px';
}
setRem();
window.addEventListener(supportsOrientationChange, function () {
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
setRem();
}, 300);
}, false);
})();