// 尺寸
getFileWidthAndHeight (file) {
const _URL = window.URL || window.webkitURL
const img = new Image()
img.onload = function () {
console.log('width , height ', img.width, img.height)
}
img.src = _URL.createObjectURL(file)
}
handleBeforeUpload (file, fileList) { // 上传回调
return new Promise(async (resolve, reject) => {
this.getFileWidthAndHeight(file) //看这里
console.log('handleBeforeUpload...', this.params, file)
const imageReg = /.(gif|jpg|jpeg|png|webp|GIF|JPG|JPEG|PNG|WEBP)$/
if (imageReg.test(file.name)) {
return this.GetUploadSinature(this.params).then(() => resolve())
}
const errText = '请选择图片上传'
this.$message.error(errText)
// eslint-disable-next-line prefer-promise-reject-errors
reject()
})
},
// 待补充,实时获取的file格式