鍍金池/ 問答/HTML/ 小程序跳轉(zhuǎn)傳遞參數(shù),到另一個頁面json.pase報錯?

小程序跳轉(zhuǎn)傳遞參數(shù),到另一個頁面json.pase報錯?

tempFilePath數(shù)據(jù) Array

clipboard.png

wx.navigateTo({
      url: `../add_mininote/index?audio=` + JSON.stringify({ serverPath: that.data.tempFilePath})
    })
  }
Unexpected end of JSON input;at "pages/add_mininote/index" page lifeCycleMethod onLoad function
SyntaxError: Unexpected end of JSON input
onLoad 是不是有一些沒過來,什么原因?qū)е碌模?br>{"serverPath":[{"tempFilePath":"http://tmp/wx6233646c3c24b6dd.o6zAJs5OCtd198A01IgZKsumvVWg.FI5bbM3dykEs3610ff761868f1a72382d40b8a8072af.durationTime
最后試了出來,因為這段鏈接中包含=號,去掉等號就不會報錯,能解決嗎?
/usr/local/files/20180522/dbb931a2-8325-4ebf-bbff-970e090acc97wx6233646c3c24b6dd.o6zAJs5OCtd198A01IgZKsumvVWg.5gb46Kp0Bdgc1dab02c700decd62d36a2b7d06f085d1.durationTime=4515.mp3
回答
編輯回答
獨特范

使用JSON.parse需嚴格遵守JSON規(guī)范。
解決方法:
將tempFilePath 進行 encodeURI() 函數(shù)轉(zhuǎn)換,就可以了。

2017年1月20日 16:17