Browse Source

图片上传修改

master
yujintao 6 years ago
parent
commit
8740a44942
  1. 8
      src/views/modules/news/news-add-or-update.vue
  2. 8
      src/views/modules/news/news-publish.vue

8
src/views/modules/news/news-add-or-update.vue

@ -328,17 +328,17 @@ export default {
},
//
handleAvatarSuccess (res, file) {
this.dataForm.newsImageUrl = URL.createObjectURL(file.raw)
this.dataForm.newsImageUrl = res.data.url
},
beforeAvatarUpload (file) {
const isJPG = file.type === 'image/jpeg' || file.type === 'png'
const isJPG = (file.type === 'image/jpeg' || file.type === 'image/png')
const isLt2M = file.size / 1024 / 1024 < 0.5
if (!isJPG) {
this.$message.error('上传头像图片只能是 JPG/PNG 格式!')
this.$message.error('上传图片只能是 JPG/PNG 格式!')
}
if (!isLt2M) {
this.$message.error('上传头像图片大小不能超过 500KB!')
this.$message.error('上传图片大小不能超过 500KB!')
}
return isJPG && isLt2M
},

8
src/views/modules/news/news-publish.vue

@ -352,17 +352,17 @@ export default {
})
}, 1000, { 'leading': true, 'trailing': false }),
handleAvatarSuccess (res, file) {
this.dataForm.newsImageUrl = URL.createObjectURL(file.raw)
this.dataForm.newsImageUrl = res.data.url
},
beforeAvatarUpload (file) {
const isJPG = file.type === 'image/jpeg' || file.type === 'png'
const isJPG = (file.type === 'image/jpeg' || file.type === 'image/png')
const isLt2M = file.size / 1024 / 1024 < 0.5
if (!isJPG) {
this.$message.error('上传头像图片只能是 JPG/PNG 格式!')
this.$message.error('上传图片只能是 JPG/PNG 格式!')
}
if (!isLt2M) {
this.$message.error('上传头像图片大小不能超过 500KB!')
this.$message.error('上传图片大小不能超过 500KB!')
}
return isJPG && isLt2M
}

Loading…
Cancel
Save