taro-ui-demo icon indicating copy to clipboard operation
taro-ui-demo copied to clipboard

在index.html中有一个监听窗口改变根节点大小

Open 521707 opened this issue 4 years ago • 0 comments

// 我修改过的 const onResize = () => { const { documentElement, style } = document const { width } = documentElement.getBoundingClientRect() if (width >= 640) return style.fontSize = "40px" style.fontSize = (width <= 320 ? 20 : width / 320 * 20) + 'px'

//这里有什么意义 ,并没有调用或者修改什么 // let v, u, // if (!v && !u) { // let n = !!navigator.appVersion.match(/AppleWebKit.Mobile./); // v = devicePixelRatio; // v = n ? v : 1, u = 1 / v // } } addEventListener("resize", () => onResize()); onResize()

// index.html原话,
!function (x) { function w() { var v, u, t, tes, s = x.document, r = s.documentElement, a = r.getBoundingClientRect().width; if (!v && !u) { var n = !!x.navigator.appVersion.match(/AppleWebKit.Mobile./); v = x.devicePixelRatio; tes = x.devicePixelRatio; v = n ? v : 1, u = 1 / v } if (a >= 640) { r.style.fontSize = "40px" } else { if (a <= 320) { r.style.fontSize = "20px" } else { r.style.fontSize = a / 320 * 20 + "px" } } } x.addEventListener("resize", function () { w() }); w() }(window);

521707 avatar Feb 28 '20 02:02 521707