为什么,wx.navigateTo到新对象,不支持 对象里面 有 & 号啊?
代码片段: https://developers.weixin.qq.com/s/Vy1si6m77Kri
let list = {
title:"小心草丛&收到" // 跳转到新页面,为什么报错? &
}
let type = 1
list = JSON.stringify(list);
wx.navigateTo({
url: '/pages/details/details' + `?list=${list}&type=${type}`,
})
/**
* details 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var self = this;
// console.log("options=>", options)
let {
list,
type
} = options;
list = JSON.parse(list) // 报错 list.title ,有 & 符号,list {字符串,对象} 都不行,官方回应下?
}
JSON.stringify后用encodeURIComponent编码,传过去再解码
let list = {
title:"小心草丛&收到", // 跳转到新页面,为什么报错? &
}
let type = 1
list = JSON.stringify(list);
let changeurl = encodeURIComponent(`${list}`)
wx.navigateTo({
url: `/test/test?changeurl=${changeurl}&type=${type}`,
})
options:
let changeurl = decodeURIComponent(options.changeurl)
let list = JSON.parse(changeurl)
console.log("4444444444",list)
wx.navigateTo
url里有两个? 第二个?后的内容自动被截掉了 怎么解决 能不能把第二个?当作字符串 不截取呢
?url=http://demo.******e.cn/*****/home?a=b&menuLevel=1
下一页的options里打印出来的是{url:http://demo.******e.cn/*****/home}
希望打印出来的是{url:http://demo.******e.cn/*****/home?a=b, menuLevel:1}
url只能是字符串
at JSON.parse (<anonymous>)
at qi.onLoad (details.js? [sm]:25)
at qi.<anonymous> (VM233 WAService.js:2)
at qi.r.__callPageLifeTime__ (VM233 WAService.js:2)
at Cn (VM233 WAService.js:2)
at VM233 WAService.js:2
at An (VM233 WAService.js:2)
at Function.<anonymous> (VM233 WAService.js:2)
at u.<anonymous> (VM233 WAService.js:2)
at u.emit (VM233 WAService.js:2)
不是有截图吗?
./details?list={"title":"小心草丛&收到"}&type=1
代码片段 https://developers.weixin.qq.com/s/Vy1si6m77Kri