uniapp如何獲取網頁地址參數

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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章