这一步console没什么问题
that.imgUrl = res.result.data.imgs; //有22个图片地址
that.textContent = res.result.data.title;
let imgs = JSON.stringify(that.imgUrl); 转换
console.log(imgs);
console.log(that.textContent);
that.$refs.uToast.hide();
uni.navigateTo({
url: '/pages/tool/dy/dyhandle?textContent=' + that.textContent + '&imgUrl=' + imgs 传递
});
下一个页面
onLoad(options) {
console.log(options) //接收到的imgUrl只有一个图片地址, 并且不传递textContent 为什么? radioUrl没有问题。 出现问题的是else if 那段语句, 甚至不进入循环判断
console.log(options)
if (options.hasOwnProperty('radioUrl')) {
this.dyShipin = true;
this.radioURL = options.radioUrl;
this.textContent = options.textContent;
} else if (options.hasOwnProperty('imgUrl')) {
this.dyTupian = true;
this.imgsURL = JSON.parse(options.imgUrl);
this.textContent = options.textContent;
console.log(options);
} else {
wx.showToast({
title: '传递错误!'
});
}
},
参考GPT和自己的思路:
根据您提供的代码,我看到您将传递的图片地址数组 that.imgUrl
转换成了 JSON 字符串格式 imgs
,然后将其作为参数传递给 uni.navigateTo
。在下一个页面的 onLoad
方法中,您使用 JSON.parse(options.imgUrl)
将其转换回原来的数组格式 imgsURL
。这里我暂时看不出您提到的所述问题,可能还需要进一步了解。
关于存在的问题,可以再检查一下几个方面:
在当前页面 that.textContent
,在跳转时传输了吗?在下一个页面中,是否设置了对应的接收参数 textContent
?
请确保传输的 imgUrl
确实包含了 22 个图片地址,并且没有被截断或修改。可以在跳转前在当前页面打印一下转换后的 imgs
,确保正确传输。
检查跳转时传递的参数名是否完全一致,包括大小写。如 textContent
和 imgUrl
。
如果仍然存在问题,可以在当前页面和下一个页面的控制台中打印相应的参数,检查接收的参数是否正确。
希望这能帮到您,如有其他问题或疑问,请随时沟通。
可以用一个变量,作为ui的参数,传进去