Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【2019-04-09】获取Url上的参数 #22

Open
Pearyman opened this issue Apr 9, 2019 · 1 comment
Open

【2019-04-09】获取Url上的参数 #22

Pearyman opened this issue Apr 9, 2019 · 1 comment

Comments

@Pearyman
Copy link
Member

Pearyman commented Apr 9, 2019

eg:

const url = "http://www.taobao.com/index.php?key0=0&key1=1&key2=2";

function getUrlParams(url,key){

}
getUrlParams(url,key0)  // return 0
@xsf0105
Copy link

xsf0105 commented Apr 17, 2019

function getUrlParams(url, key){
	var oUrl = new URL(url);
	return oUrl.searchParams.get(key);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants