uniapp+firstUI——上传视频组件fui-upload-video

html 复制代码
<fui-upload-video immediate :url="uploadUrl" ref="videoRef" @success="successVideo" @error="errorVideo"
					@complete="completeVideo" width="410" height="250" :header="header"></fui-upload-video>
html 复制代码
<script setup>
	import {
		ref,
		reactive,
		shallowRef
	} from 'vue'
	import {
		onLoad,
		onShow,
		onReachBottom
	} from '@dcloudio/uni-app'
	import i from '@/libs/common/index.js'
	import api from '@/request/api.js'
	import throttle from '@/libs/function/throttle.js'
	import config from '@/libs/config/index.js'
	import {
		userStore
	} from '@/store/userStore.js'
	import {
		commonStore
	} from '@/store/commonStore.js'
	const user = userStore()
	const common = commonStore()
	const fault_video = ref([]) //视频
	const uploadUrl = config.apiUrl + '/api/common/upload'
	const videoRef = shallowRef() //视频组件名称
	const status = ref('') //视频上传状态
	const header = ref({
		'token': uni.getStorageSync('userStorage').token
	})
	const video_url = ref([]) //视频预览列表
	// 视频上传
	function successVideo(e) {
		let res = JSON.parse(e.res.data.replace(/\ufeff/g, "") || "{}")
		status.status = e.status
		if (res.data.url) {
			videoRef.value.result(res.data.url, e.index)
		}
	}
	//上传失败时触发
	function errorVideo(e) {
		status.status = e.status
	}
	//选择视频或上传完成时触发
	function completeVideo(e) {
		status.status = e.status
		video_url.value = e.urls
		if (status.status === 'success' && e.action === 'upload') {
			i.success('上传完成!')
			//已上传完成的视频列表 this.urls
			console.log(video_url.value)
		}
	}
</script>
相关推荐
ZoeLandia1 小时前
React08:自定义 Hook
开发语言·前端·react.js·typescript
2601_949970691 小时前
msgpackr 跨端三方库仓颉适配全流程
前端·javascript·flutter
Software攻城狮1 小时前
【uniapp和普通web 端开发的区别】
前端·uni-app·notepad++
IT_陈寒1 小时前
Vue项目实战经验分享:动态组件在Keep-Alive下的缓存陷阱
前端·人工智能·后端
2501_915921431 小时前
iOS 实时日志怎么看?KeyMob 的日志过滤、崩溃报告与符号化
android·ios·小程序·https·uni-app·iphone·webview
数智奔流1 小时前
MiniMax的低价攻势,撞上“背题”疑云
前端·javascript·算法
2601_954005621 小时前
11 种触发 × 18 种行为:ricon 交互编排系统全解
前端·后端·物联网·数学建模·信息可视化·交互
某人辛木1 小时前
Web前端框架应用(三)路由
前端·javascript·前端框架
风骏时光牛马2 小时前
智能任务协作Agent
前端