我用的element 的上传功能
<el-upload ref="iconUrl" :action="iconUrlAction" name="upload" :on-success="thumbnailSuccess">
<div class="dis_flex">
<div>
<div class="uploadBut">
<el-button size="small" type="primary">点击上传</el-button>
</div>
</div>
</div>
</el-upload>
// 文件上传成功时的钩子
thumbnailSuccess(res: any, file: any) {
if (res) {
let audio: any = document.createElement("audio"); //生成一个audio元素
audio.src = res.path; //音乐的路径
audio.addEventListener("canplay", function () {
console.log(parseInt(audio.duration));
});
}
}