1.在manifest.json文件中加入以下代码
"screenOrientation" : [
"portrait-primary",
"portrait-secondary",
"landscape-primary",
"landscape-secondary"
],
2.为video组件添加fullscreenchange监听事件,我们还可以为video组件添加fullscreenchange监听事件。当视频退出全屏播放时,通过监听事件手动设置屏幕方向为竖屏
<template>
<video @fullscreenchange="handleFullscreenChange" src="your-video-url"></video>
</template>
<script>
export default {
methods: {
handleFullscreenChange() {
// 判断是否退出全屏
if (!this.$refs.video.webkitDisplayingFullscreen) {
// 手动设置屏幕方向为竖屏
screen.orientation.lock('portrait-primary');
}
}
}
}
</script>
3.切记需要重新打基座,必须!!!!!!