http://172.16.20.218:8080/m/MGU20201126001-001/index.html?username=admin&password=123#/write
浏览器输入这个链接,这个url中location的属性如下:
hash: "#/write" host: "172.16.20.218:8080" hostname: "172.16.20.218" href: "http://172.16.20.218:8080/m/MGU20201126001-001/index.html#/write" origin: "http://172.16.20.218:8080" pathname: "/m/MGU20201126001-001/index.html" port: "8080" protocol: "http:" search: "?username=admin&password=123"
小窍门 :
需要获取当前url 不需要参数的话,那就是 location.origin+location.pathname
需要获取当前 完整的url,那就是 location.href