1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| const baseSize = 16
| function setRem() {
| const scale = document.documentElement.clientWidth / 828
| document.documentElement.style.fontSize = baseSize * scale + 'px'
| }
| function isMobile() {
| let userAgentInfo = navigator.userAgent;
| let Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
| let getArr = Agents.filter(i => userAgentInfo.includes(i));
| return getArr.length ? true : false;
| }
| if (isMobile()) {
| setRem()
| }
| window.onresize = function () {
| if (isMobile()) {
| setRem()
| }
|
| }
|
|