参考链接:https://www.jianshu.com/p/8a50d9b32d0f
- 横竖屏页面
<template>
<view>
<button type="default" @click="horiScreen">横屏</button>
</view>
</template>
<script>
export default {
data() {
return {
}
},
onResize() {
},
onShow() {
//#ifdef APP-PLUS
uni.showLoading({
title: "加载中..."
})
setTimeout(() => {
plus.screen.unlockOrientation(); //解除锁定屏幕方向
plus.screen.lockOrientation('landscape-primary');//横屏锁定
uni.hideLoading();
}, 1200)
//#endif
},
onUnload() {
// #ifdef APP-PLUS
plus.screen.unlockOrientation(); //解除锁定屏幕方向
plus.screen.lockOrientation('portrait-primary'); //竖屏锁定
uni.navigateTo({
url: '/pages/transfer-page'
})
// #endif
}
}
</script>
<style lang="less" scoped>
</style>
- 中转页
<template>
<view></view>
</template>
<script>
export default {
data() {
return {}
},
onLoad() {
uni.navigateBack({
delta: 1
})
},
methods: {}
}
</script>
<style lang="less" scoped>
</style>