<el-upload
:on-change="uploadVideoChange">
<el-button size="small" type="primary">
<i class="el-icon-upload" />点击上传
</el-button>
</el-upload>
uploadVideoChange (file, fileList) {
// 防止触发两次
if (file.status !== 'ready') return
const getVideoInfo = new Promise((resolve) => {
const videoElement = document.createElement("video");
videoElement.src = URL.createObjectURL(file.raw);
videoElement.addEventListener("loadedmetadata", function () {
resolve({
duration: videoElement.duration,
height: videoElement.videoHeight,
videoElement.videoWidth
});
});
});
getVideoInfo.then((videoInfo) => {
console.log(videoInfo);
})
}