|
@@ -6,11 +6,11 @@
|
|
var rootItem, rootStyle;
|
|
var rootItem, rootStyle;
|
|
|
|
|
|
function refreshRem() {
|
|
function refreshRem() {
|
|
- var width = docEl.getBoundingClientRect().width;
|
|
|
|
- console.log('=======width=======================', width);
|
|
|
|
|
|
+ var width = localStorage.width;
|
|
|
|
+ if (!width) return;
|
|
|
|
|
|
//与淘宝做法不同,直接采用简单的rem换算方法1rem=100px
|
|
//与淘宝做法不同,直接采用简单的rem换算方法1rem=100px
|
|
- var rem = (2560 * 100) / 2560;
|
|
|
|
|
|
+ var rem = (width * 100) / 2560;
|
|
//兼容UC开始
|
|
//兼容UC开始
|
|
rootStyle = 'html{font-size:' + rem + 'px !important}';
|
|
rootStyle = 'html{font-size:' + rem + 'px !important}';
|
|
rootItem =
|
|
rootItem =
|
|
@@ -65,4 +65,12 @@
|
|
false,
|
|
false,
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ window.refreshRem = refreshRem;
|
|
|
|
+ window.addEventListener('storage', (e) => {
|
|
|
|
+ console.log(e);
|
|
|
|
+ if (e.key == 'width') {
|
|
|
|
+ refreshRem();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
})();
|
|
})();
|