fix: await nextTick before setting video src on first preview

This commit is contained in:
2026-06-08 13:48:50 +08:00
parent a0749261bf
commit e68ed9c962

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, watch, computed } from 'vue'
import { ref, watch, computed, nextTick } from 'vue'
const props = defineProps<{
videoUrl: string | null
@@ -9,7 +9,8 @@ const videoRef = ref<HTMLVideoElement | null>(null)
const playing = ref(false)
const paused = ref(false)
watch(() => props.videoUrl, (url) => {
watch(() => props.videoUrl, async (url) => {
await nextTick()
if (!videoRef.value || !url) return
videoRef.value.src = url
playing.value = false