獲取url的路徑信息


http://localhost:3001/?id=123&type=456#/



  getQueryName = (name) => {
    var result = (window.location.search || window.location.href).match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
    if (result == null || result.length < 1) {
      return "";
    }
    return decodeURIComponent(result[1]);
  }

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