MrShi
6 天以前 97158794d69fd2beee1bf27577aa7cadea8d847d
admin/src/components/common/UploadImage.vue
@@ -40,6 +40,10 @@
      type: Number,
      default: () => null
    },
    size: {
      type: Number,
      default: () => 1
    },
    uploadData: Object
  },
  data () {
@@ -67,13 +71,13 @@
    beforeUpload (file) {
      this.$emit('beginUpload')
      const isJPGOrPNG = file.type === 'image/jpeg' || file.type === 'image/png'
      const isLt2M = file.size / 1024 / 1024 < 1; // 500kb
      const isLt2M = file.size / 1024 / 1024 < this.size;
      if (!isJPGOrPNG) {
        this.$message.error('上传头像图片只能是 JPG/PNG 格式!');
        return false
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 500KB!');
        this.$message.error(`上传图片大小不能超过${this.size}mb!`);
        return false
      }
      return true