// window.onload = function () { // const appRef = document.getElementById("app") // // 初始化页面 // calcRate() // window.addEventListener('resize', calcRate) // function calcRate () { // if (!appRef) return // // 获取浏览器缩放比例 // const browserRoom = getZoom() // /** // * 1. 先将宽高乘上浏览器缩放倍数x // * 2. 再将整个页面用scale缩放 1/x 倍 // * 在视觉上,就感觉页面没有缩放 // */ // // 宽高 // const w = window.innerWidth * browserRoom // const h = window.innerHeight * browserRoom // // scale缩放比例 // const scl = parseFloat((1 / browserRoom).toFixed(5)) // // 页面重绘处理 // appRef.style.width = `${w}px` // appRef.style.height = `${h}px` // appRef.style.transform = `scale(${scl}, ${scl}) translate(-50%, -50%)` // // 页面重绘完成后,再进行echarts重绘,保证echarts图表的自适应性 // myChart.resize() // myChart2.resize() // } // // 获取浏览器缩放比例 // function getZoom() { // let ratio = 0, // screen = window.screen, // ua = navigator.userAgent.toLowerCase(); // if (window.devicePixelRatio !== undefined) { // ratio = window.devicePixelRatio; // } else if (~ua.indexOf('msie')) { // if (screen.deviceXDPI && screen.logicalXDPI) { // ratio = screen.deviceXDPI / screen.logicalXDPI; // } // } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) { // ratio = window.outerWidth / window.innerWidth; // } // if (ratio){ // ratio = Math.round(ratio * 100); // } // return parseFloat(ratio/100).toFixed(2); // } // }