uniapp在在页面跳转时,若URL太长的字符串会导致数据传递失败

url有长度限制,太长的字符串会传递失败,可使用窗体通信、全局变量,或encodeURIComponent等多种方式解决,如下为encodeURIComponent示例的解决方法。

<navigator :url="'/pages/test/test?item='+ encodeURIComponent(JSON.stringify(item))">navigator>
// 在test.vue页面接受参数
onLoad: function (option) {
    const item = JSON.parse(decodeURIComponent(option.item));
}

内容来自uniapp官网

转载于:https://www.cnblogs.com/lwming/p/11498274.html

你可能感兴趣的:(uniapp在在页面跳转时,若URL太长的字符串会导致数据传递失败)