vue手机端横屏竖屏切换

1.建一个空白的vue文件,添加上如下代码

data() {
  this.$router.go(-1)
  return {}
}
 
2.在需要横屏竖屏切换的页面中加入如下代码:
beforeMount() {
  window.addEventListener('orientationchange', () => {
    this.$router.push({ path: '/空vue的路由地址' })  
  })
}

猜你喜欢

转载自www.cnblogs.com/yanjunwu/p/10033949.html