Golang 陣列(切片)的值傳遞與引用傳遞
阿新 • • 發佈:2020-12-14
技術標籤:小程式javascript
開發微信小程式的過程中,用wx.request獲取伺服器的資料時,發現總是收不到伺服器傳來的json資料
錯誤程式碼如下:
wx.request({
url: 'http://localhost:8000/v1/quote',
data: {},
header: {
'content-type': 'application/json'
},
responseType : 'json',
success (res) {
console.log(res)
that.setData ({
motto: res.data.content+"\n------"+res.data.author
})
報錯資訊:
Uncaught DOMException: Failed to read the ‘responseText’ property from ‘XMLHttpRequest’: The value is only accessible if the object’s ‘responseType’ is ‘’ or ‘text’ (was ‘json’).
截圖:
解決方案:
仔細讀報錯可以發現,wx.request中的“responseType”項只有兩種選項,’‘或者’text’(之前一直用的“json”)
ps:應該是微信最近改的規則,前兩天都還可以用json來著,今天突然就報錯了……