我想要获取以下id spa
以下代码(传参要加问好!!)code
function getUrlParam(id) { var regExp = new RegExp('([?]|&)' + id+ '=([^&]*)(&|$)'); var result = window.location.href.match(regExp); if (result) { return decodeURIComponent(result[2]); } else { return null; } } var id = getUrlParam("id"); alert(id);
效果:blog