<template>
<div>
<div class="video">
<video :src="videoUrl" controls="controls" autoplay="autoplay" width="100%" height="100%"></video>
</div>
<div class="video-list">
<ul>
<li v-for="(item, index) in videoList" :key="index" @click="videoUrl = item.url">
<img :src="item.cover" alt="">
</li>
</ul>
</div>
</div>
</template>
<script>
import { getVideoUrl } from '@/api/video'
export default {
data() {
return {
videoList: [],
videoUrl: ''
}
},
created() {
this.getVideoUrl(); // 添加created生命周期调用
},
methods: {
getVideoUrl() {
return getVideoUrl(this.queryParams) // Add return statement
.then(response => {
console.log('接口响应数据:', res); // 添加console打印
if (res.code == 200) {
this.videoList = res.data;
this.videoUrl = this.videoList[0]?.url;
}
}).catch(err => {
console.error('接口请求错误:', err); // 添加错误处理
});
},
}
}
</script>
<style lang="css" scoped></style>
export function getVideoUrl(query) {
return request({
url: '/front/video/url',
method: 'get',
params: query
})
}请求不出来数据,还报错
不太清楚我是哪里有错误,有没有大佬能给我解答一下