上传文件a-upload

    handleChange (info) {
      console.log(info, 'info')
      this.uploadInfo = {
        file: null,
        fileName: ''
      }
      const file = info.target.files[0]
      if (file && /\.(xlsx|xls)$/i.test(file.name)) {
        this.uploadInfo.file = file || ''
        this.uploadInfo.fileName = file.name || ''
      } else {
        this.uploadInfo = {
          file: null,
          fileName: ''
        }
        this.$message.error('只能上传.xls或者.xlsx格式的文件')
        return false
      }
      if (file.size / 1024 / 1024 >= 2) {
        this.$message.error('文件打大小超过2M!')
        return false
      }
      console.log(this.uploadInfo, 'this.uploadInfo')
    }

你可能感兴趣的:(vue.js,前端,javascript)