| | |
| | | |
| | | // 设置 init 函数 |
| | | function init() { |
| | | if (_this) { |
| | | let innerWH = { |
| | | innerWidth: window.innerWidth, |
| | | innerHeight: window.innerHeight, |
| | | } |
| | | _this.$store.commit('setWindowSize', innerWH); |
| | | // console.log(' window.innerWidth', window.innerWidth); |
| | | // console.log(' window.innerHeight', window.innerHeight); |
| | | |
| | | if (_this) { |
| | | let innerWH = { |
| | | innerWidth: window.innerWidth, |
| | | innerHeight: window.innerHeight, |
| | | } |
| | | _this.$store.commit('setWindowSize', innerWH); |
| | | // console.log(' window.innerWidth', window.innerWidth); |
| | | // console.log(' window.innerHeight', window.innerHeight); |
| | | _this.$store.commit("setWindowSizeHeight", innerWH.innerHeight); |
| | | _this.$store.commit("setScreenSize", { |
| | | w: window.screen.width, |
| | | h: window.screen.height |
| | | }); |
| | | _this.$store.dispatch("changeZoom"); |
| | | } |
| | | } |
| | | |
| | | // 节流 ms 触发间隔毫秒 |
| | |
| | | var lastClick = Date.now() - ms; |
| | | // 初始化 |
| | | setTimeout(() => { |
| | | init(); |
| | | init(); |
| | | }, 500); |
| | | // 改变窗口大小时重新设置 rem |
| | | // window.onresize = function () { |
| | |
| | | // } |
| | | // } |
| | | window.addEventListener('resize', () => { |
| | | // 节流 |
| | | if (Date.now() - lastClick >= ms) { |
| | | init(); |
| | | lastClick = Date.now(); |
| | | } |
| | | }, false) |
| | | // 节流 |
| | | if (Date.now() - lastClick >= ms) { |
| | | init(); |
| | | lastClick = Date.now(); |
| | | } |
| | | }, false) |