在 a-upload中加上:headers=“headers”

       <a-upload
                  :action="this.$baseURL+'/image/upload'"
                  :headers="headers"
                  :beforeUpload="beforeUpload"
                  :multiple="true"
                  :file-list="fileList"
                  @change="handleChange"
                >
                  <a-button class="upbtn"> <a-icon type="upload" /> Upload </a-button>
                  <div style="font-size: 12px;color: #8392A7;margin-top: 16px;">图标最大尺寸为180*52比例,大小不能超过20M</div>
                </a-upload>

然后在data中添加代码如下
this.$store.state.user.token(该项目通过vuex取的,具体项目按照自己的vuex写法取得)

  headers: {
          'Access-Token-PC': this.$store.state.user.token,
           //   'Authentication': this.$store.state.user.token,
          // 'Content-Type': 'application/json'
        },
Logo

前往低代码交流专区

更多推荐