页面跳转拼接传值是(页面传参 当缓存乱码时候)数组对象格式转码

作者: 小枫枫

临枫的项目经历分享给你们啦~

扫码交朋友

标签:

特别声明:文章有少部分为网络转载,资源使用一般不提供任何帮助,特殊资源除外,如有侵权请联系!

跳转页面时候使用  使用JavaScript encodeURIComponent() 函数转码字符串作为 URI 组件进行编码

setPageInfo(item){
    location.href = 'newPage.html?data=' + encodeURIComponent(JSON.stringify(item))
}

 

页面使用方法 然后调用 decodeURIComponent 解码即可

getItem(name) {
    let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    console.log(window.location.search.substr(1));
    let r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return decodeURIComponent(r[2]);
    }
    return null;
}


let q = JSON.parse(this.getItem('data'));

 

 

 

-----------------方法二------------------

js的escape()和unescape() 函数 来进行加密和解密

提示:ECMAScript v3 已从标准中删除了 unescape() 函数,并反对使用它,因此应该用 decodeURI() 和 decodeURIComponent() 取而代之。

本文最后更新于2019-12-25,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!
分享到:
打赏

评论

切换注册

登录

您也可以使用第三方帐号快捷登录

切换登录

注册

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏