diff --git a/src/views/modules/news/news-add-or-update.vue b/src/views/modules/news/news-add-or-update.vue index 2ca45086..365e99d1 100644 --- a/src/views/modules/news/news-add-or-update.vue +++ b/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 }, diff --git a/src/views/modules/news/news-publish.vue b/src/views/modules/news/news-publish.vue index 839d4c5c..a173c988 100644 --- a/src/views/modules/news/news-publish.vue +++ b/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 }