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

2020-03-07  本文已影响0人  laogui_

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 "";

        }

上一篇 下一篇

猜你喜欢

热点阅读