美文网首页
uniapp中如何获取网页地址参数

uniapp中如何获取网页地址参数

作者: laogui_ | 来源:发表于2020-03-07 12:17 被阅读0次

uniapp 中要获取地址 http://xxxxxxx/#/pages/my/index?id=124 的参数

1:获取本页面的地址

    let local = location.href; 

2:获取参数

     let payment_id = this.getParam(local, "payment_id");

     //获取url中的参数

        getParam(path, name) {

        var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");

        if (reg.test(path))

        return unescape(RegExp.$2.replace(/\+/g, " "));

        return "";

        }

相关文章

网友评论

      本文标题:uniapp中如何获取网页地址参数

      本文链接:https://www.haomeiwen.com/subject/xuiqdhtx.html