async beforeUploadPicture(file) {
const width = 347
const height = 115
const isSize = await new Promise(function(resolve, reject) {
const _URL = window.URL || window.webkitURL
const img = new Image()
img.onload = function() {
const valid = img.width === width && img.height === height
valid ? resolve() : reject()
}
img.src = _URL.createObjectURL(file)
}).then(() => {
return true
}, () => {
return false
})
if (!isSize) {
this.$message.error('请上传尺寸为' + width + '*' + height + '的图片!')
return Promise.reject()
}
},
js上传图片限制图片尺寸方法
最新推荐文章于 2024-08-26 17:09:23 发布