http://localhost:8080/?state=app&code=021axrkH0Il7Df2bEQkH0DMjkH0axrkP
准确获取code的值
getQueryString(name) { let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); let r = window.location.search.substr(1).match(reg); if (r != null) { return unescape(r[2]); } return null; }
getQueryString('code')//021axrkH0Il7Df2bEQkH0DMjkH0axrkP
getQueryString('state')//app