Get parameters from url address

1. Get the url address of the current window:

'http://172.20.236.77:8080/szzxzhhwHYSYY/index.html?code=fwnadfgfddfgfddfgffdgdgd&state=STATE#/'

 let url=window.location.href

2. Intercept the characters after "?" in the URL address

let urll=url.split('?')[1]

code=fwnadfgfddfgfddfgffdgdgd&state=STATE#/

3. Intercept the part before #

let tt=urll.split('#')[0]

code=fwnadfgfddfgfddfgffdgdgd&state=STATE

4. Place the parameters in the URLSearchParams function

 let getqys = new URLSearchParams('?' + tt)

getqys.get('code   ')

Guess you like

Origin blog.csdn.net/weixin_61728046/article/details/132038606