xunji-shiping.vue
1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<template>
<view class="video-container">
<!-- 视频播放器 -->
<up-navbar :autoBack="true" bgColor="transparent" leftIconColor="#fff"> </up-navbar>
<video
id="myVideo"
:src="videoUrl"
controls
autoplay
muted
object-fit="contain"
class="video-player"
@error="videoErrorCallback"
>
</video>
</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
const videoUrl = ref('');
onLoad((options) => {
videoUrl.value = options.url;
});
// 视频错误回调
const videoErrorCallback = (e) => {
console.error('视频播放错误:', e.detail);
uni.showToast({
title: '视频加载失败',
icon: 'none',
});
};
</script>
<style lang="scss">
.video-container {
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #000;
}
.video-player {
width: 100vw;
height: 50vh;
}
.video-tips {
padding: 20rpx;
text-align: center;
color: #fff;
font-size: 28rpx;
background-color: rgba(0, 0, 0, 0.5);
}
</style>