<el-upload
class="avatar-uploader el-upload--text"
action=""
:auto-upload="false"
:show-file-list="false"
:on-change="getFile"
:on-remove="handleRemove"
accept=".mp4"
:limit="1"
drag
style="margin-top:50px"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">只能上传MP4文件,且不超过50MB</div>
</el-upload>
getFile(file, fileList) {
let fileType = [".mp4", ".MP4"];
let { name, size } = file;
let hzIndex = name.lastIndexOf(".");
let nameLen = name.length;
let hz = name.substring(hzIndex, nameLen);
let videoSize = parseFloat(size) / 1024 / 1024 > 50;
if (!fileType.includes(hz) || videoSize) {
console.log(this.ItemPicList);
this.$message.error({
message: "注意:视频格式需要为50MB以下的MP4文件!",
});
} else {
let URL = window.URL || window.webkitURL;
this.AUDIO = URL.createObjectURL(file.raw); /用这个赋值给需要的视频组件就行 就能显示本地视频了
console.log(this.AUDIO);
this.getVideFile(file.raw).then((res) => {
});
}
this.video = [1]
},