【发布时间】:2017-12-21 19:56:12
【问题描述】:
我有min-height: 100vh的页面
它在移动浏览器上呈现,底部有一些溢出。我用这个脚本来修复它:
methods: {
calcVH() {
const vH = Math.max(document.documentElement.clientHeight, window.innerHeight, window.screen.height || 0)
document.getElementById('app').style.height = vH + 'px';
}
},
mounted() {
this.calcVH();
window.addEventListener('onorientationchange', this.calcVH, true);
window.addEventListener('resize', this.calcVH, true);
}
它在模拟器中运行正常,但在 chrome/safari 移动设备上无法运行。 有没有人遇到同样的问题?
【问题讨论】:
-
不工作时是什么样子的?
-
我认为正确的事件名称是
orientationchange(没有on前缀)。 -
我认为这可能对您有所帮助:stackoverflow.com/questions/58886797/…
标签: vue.js vuejs2 mobile-safari mobile-chrome