+
95
-

回答

nvue中原生组件video使用v-show来隐藏是不起作用的,我们可以使用ransform: translateY把原生对象顶出视线范围来实现隐藏和显示,示例代码如下:

<template>
	<view>
		<video :style="'transform: translateY('+top+'px);'" v-show="ishow" autoplay style="height:750rpx;width:750rpx;" src="https://repo.bfw.wiki/bfwrepo/video/modushanghai.mp4"></video>
		<button @tap="hidevideo">显示或隐藏</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				ishow:true,
				top:0,
			}
		},
		methods: {
			hidevideo(){
				if(this.top==0){
						this.top=11000;
				}else{
						this.top=0;
				}
			
			}
		}
	}
</script>

<style>

</style>

网友回复

我知道答案,我要回答