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官网

posted @ 2019-09-10 16:36  lwming  阅读(3159)  评论(0编辑  收藏  举报