当前界面跳转方法
var notes = {name:‘xiaohua’,phone:‘10086’}
let str = JSON.stringify(notes);
wx.navigateTo({
url: ‘…/showHouse/showHouse?jsonStr’+str,
})
跳转界面onload里面处理
let item = JSON.parse(options.jsonStr);
console.log(item)
报错信息 Unexpected token u in JSON at position 0;at “pages/showHouse/showHouse” page lifeCycleMethod onLoad function
SyntaxError: Unexpected token u in JSON at position 0
```JS
buy() {
let productStr = JSON.stringify(this.data.productData)
wx.navigateTo({
url: `…/buy/buy?productStr=${productStr}`
})
}
```
```JS
/**
* 生命周期函数–监听页面加载
*/
onLoad: function (options) {
/* console.log(options.productStr)
console.log(typeof(options.productStr)) */
/* let productObj = JSON.parse(options.productStr) */
/* console.log(typeof(productObj)) */
let codeStr = encodeURIComponent(options.productStr)
let productCodeObj = JSON.parse(codeStr)
let productObj = decodeURIComponent(productCodeObj)
this.setData({
product: productObj
})
},
```
问题好多了,晕死了,怎么解决的