1.饿了么的上传组件 <el-upload>,监听他的变化 on-change
<el-upload
:on-change="uploadVideoChange"
>
<el-button size="small" type="primary">
<i class="el-icon-upload" />点击上传
</el-button>
</el-upload>
我看很多其他文章都是在 beforeUpload那里监听,我这里不好用,就用在了on change上
2.可以拿到上传的file对象
!!注意 : 这里的file对象是elemenui自己的对象,我们要把对象中的raw当做原生的对象传到方法中去
uploadVideoChange(file) {
this.getVideoMsg(file.raw).then((videoinfo) => {
const { duration, height, width } = videoinfo;
//获取到视频的时长,高度,宽度
});
//其他操作
},