小程序页面跳转传参参数值为url时参数丢失

小程序在进行页面跳转的时候,如果url传递的数据中有?,=等特殊符号,会把传的数据截断

所以就需要我们使用编码和解码的函数了

encodeURIComponent和decodeURIComponent

1.首先我们把数据编码

data = encodeURIComponent(JSON.stringify(data));

2.然后传过去以后解码

let decodeData = decodeURIComponent(opstion.data);
            let data = JSON.parse(decodeData);

你可能感兴趣的:(小程序页面跳转传参参数值为url时参数丢失)