elementUI el-upload上传前端获取视频时长
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
1.elementUI el-upload组件上传,on-change 触发校验
<el-upload size="small" v-if="!fileList.length"
class="upload-demo"
:action="uploadUrl"
:headers="headers"
:on-change="onChange"
:on-success="onSuccess"
:on-exceed ="onExceed"
:on-remove="handleRemove"
:before-upload="beforeUpload"
:multiple = 'false'
accept=".mp4,.MP4"
:limit="1"
list-type="picture-card"
:file-list="fileList">
<div class="upload-img-modify"></div>
<div slot="tip" class="el-upload__tip">请上传mp4格式的视频文件</div>
</el-upload>
2. audio获取录音时长,也可获取视频的时长
// 文件上传onchange事件
onChange(file, fileList){
let that = this;
let imgSize = Number(file.size / 1024 / 1024);
if (imgSize > 100) {
this.$message.info('视频大小不能大于100M');
this.fileList = [];
return;
}
var url = URL.createObjectURL(file.raw);//获取录音时长
var audioElement = new Audio(url);//audio也可获取视频的时长
var duration;
audioElement.addEventListener("loadedmetadata", function (_event) {
duration = audioElement.duration;
that.formAdd.videoTime = parseInt(duration);
});
this.fileList = fileList;
},
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:3 个月前 )
c345bb45
7 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献2条内容
所有评论(0)