uni-app中swiper組件加入視頻后無法全屏顯示方案解決
今天,在寫uni-app的代碼過程中,發(fā)現(xiàn)swiper組件里面的視頻不能占全屏,出不來效果,雖然官網(wǎng)也說
自動設(shè)置了100%是沒錯,但是,再次設(shè)置寬高100%,不起作用,同時還會導(dǎo)致swiper組件不顯示。這問題真是讓人搞到頭皮發(fā)麻。
問題如下:
解決方案:
代碼如下:
<template> <view class="videoList"> <view class="swiper-box"> <swiper class="swiper" :vertical="true"> <swiper-item class="swiper-item"> <video-player></video-player> </swiper-item> <swiper-item class="swiper-item"> <video-player></video-player> </swiper-item> <swiper-item class="swiper-item"> <video-player></video-player> </swiper-item> </swiper> </view> </view> </template> <script> import videoPlayer from "@/pages/components/videoPlayer"; export default { data() { return { } }, onLoad() { }, methods: { }, components: { videoPlayer } } </script> <style> .videoList { width: 100%; height: 100%; } .swiper-box { height: 100vh; } .swiper { height: 100vh; } .swiper-item { height: 100vh; } </style>
主要就是height:100%變成100vh;
100vh其實就是占據(jù)全屏元素,和屏幕高度一致
效果如圖:
————————————————
版權(quán)聲明:本文為CSDN博主「無語,人生的過客? ? ?」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/li22356/article/details/118970181
浙公網(wǎng)安備 33010602011771號