template:
<a-upload
:before-upload="beforeUpload"
></a-upload>
methods:
// 上传前的判断
beforeUpload(file, files) {
let isFileType = true // 文件类型
let isFileSize = true // 文件大小
var url = URL.createObjectURL(file)
var audioElement = new Audio(url)
var duration = parseInt(audioElement.duration)
audioElement.addEventListener('loadedmetadata', () => {
duration = parseInt(audioElement.duration) // 时长为秒,取整
console.log(parseInt(audioElement.duration), '上传视频的时长')
this.$emit('cTime', duration)
})