xsnow
机遇总是留给有准备的人

设置with-credentials属性即可支持

<template>
 <el-upload
    ref="upload"
    drag
    :action="action"
    with-credentials
    :auto-upload="false"
    :on-success="handleSuccess"
    :on-error="handleError"
    >
    <i class="el-icon-upload"></i>
    <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  </el-upload>
</template>

<script>
export default {
  methods: {
    handleSuccess(res) {
      const { code } = res
      if (code === 1) {
        this.$message({
          message: '上传成功!',
          type: 'success',
        })
      }
      this.$refs.upload.clearFiles()
      this.hide()
    },
    handleError() {
      this.$message({
        message: '上传失败!',
        type: 'error',
      })
    },
  },
}
</script>
posted on 2021-11-15 18:30  xsnow  阅读(960)  评论(0编辑  收藏  举报