onMounted(() => {
// 判断当前是横竖屏
var widtha = window.screen.width;
var heightb = window.screen.height;
if (widtha > heightb) {
// 横屏
screenState.value = false;
} else {
screenState.value = false;
}
});
// 监听横竖屏发生变化
window.addEventListener(
"orientationchange",
function () {
if (window.orientation === 90) {
commentScreen.value = true;
}
if (window.orientation === 0) {
commentScreen.value = false;
}
},
false
);
// css
@media screen and(max-width:1180px) {
.desc_inline {
display: inline-block;
width: 64%;
}
}
@media screen and(max-width:820px) {
.desc_inline {
display: block;
width: 100%;
}
}
判断横屏还是竖屏,监听横竖屏切换
最新推荐文章于 2024-06-12 17:54:48 发布