1.建一個空白的vue文件,添加上如下代碼
data() {
this.$router.go(-1)
return {}
}
2.在需要橫屏豎屏切換的頁面中加入如下代碼:
beforeMount() {
window.addEventListener('orientationchange', () => {
this.$router.push({ path: '/空vue的路由地址' })
})
}