鍍金池/ 問答/HTML/ vue 上傳圖片報錯

vue 上傳圖片報錯

axios({
      method: 'post',
      url: 'http://193.112.56.202:8001/api/upload/imageData',
      headers: {
        'Access-Control-Allow-Origin': '*',
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      params: {
        imgFile1: rst.base64
      }
    }).then((res) => {
      this.peopleImg = res.data.fileNames[0]
    })
    

我用post上傳base64圖片,為什么上傳成功后base64會拼接到url上?這導(dǎo)致了有時候請求過長而請求失敗,什么原因?麻煩大佬解答下,在線等

clipboard.png

回答
編輯回答
鐧簞噯
axios({
      method: 'post',
      url: 'http://193.112.56.202:8001/api/upload/imageData',
      headers: {
        'Access-Control-Allow-Origin': '*',
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data: { //此處為post請求用data,get請求用params
        imgFile1: rst.base64
      }
    }).then((res) => {
      this.peopleImg = res.data.fileNames[0]
    })
2017年1月16日 06:43