最后在网上参考了其他人的一份解决方案,正好解决了我的问题直接上代码
创建一个uni组件,通过用iframe作为主体,嵌入video组件,让页面跟着div滑动
<template>
<iframe :onload="onloadCode" style="width:100%;height:100%;border:1px solid #fff;background: #000;"></iframe>
</template>
<script setup>
const props = defineProps({
videoUrl: String
})
let onloadCode = `
const url = '${props.videoUrl}'
this.contentWindow.document.body.innerHTML = '<video style="width: 100%;height: 100%" controls="controls" src="'+url+'"></video>';
`
</script>
在页面中使用新建的组件
<MyVideo :videoUrl="videoUrl"></MyVideo>
作者:Yvie
链接:https://www.jianshu.com/p/e9e8041c6f22