当发请求后拿到数据需要对数据进行处理,判断是视频就显示视频,图片显示图片
<video v-if="item.isVideoImg" controls :src="item.industryVideos"></video>
<img v-else :src="item.industryVideos">
handleIndustryList() {
let params = {
currentPage: this.currentPage,
pageSize: this.pageSize,
}
home.industryMore(params).then(res=>{
this.planList = res.data.records
this.planList.forEach((item)=>{
if (!item.industryVideos) return
const videoExtensions = ['.mp4', '.avi', '.mov'];
let arr = item.industryVideos.substring( item.industryVideos.lastIndexOf('.'));
item.isVideoImg = videoExtensions.includes(arr)
return item
})
})
},