beforeCoverUpload: (file) => {
const isLtM = file.size / 1024 / 1024 < 2
// 如果图片的大小超过 2MB 的话,直接 return false
if (!isLtM) {
Toast.warning('上传图片大小不能超过 2MB!')
return false
}
return new Promise(function (resolve, reject) {
let reader = new FileReader()
reader.onload = function (event) {
let image = new Image()
image.onload = function () {
let width = this.width
let height = this.height
console.log(width,height)
if (width !== 1080 || height !== 1920) {
Toast.warning('背景图片像素必须为1080*1920')
reject()
}
resolve()
}
image.src = event.target.result
}
reader.readAsDataURL(file)
})
},