vue手机端横屏竖屏切换

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

data() {
  this.$router.go(-1)
  return {}
}
 
2.在需要横屏竖屏切换的页面中加入如下代码:
beforeMount() {
  window.addEventListener('orientationchange', () => {
    this.$router.push({ path: '/空vue的路由地址' })  
  })
}
posted @ 2018-11-28 18:53  NewObject_1  阅读(8302)  评论(0编辑  收藏  举报