很容易忘记location中的各个属性,每次用到的时候还要查,于是总结下来,便于以后查看。
比如下面这个url:
http://172.16.20.218:8080/m/MGU20201126001-001/index.html#/write
在chrome浏览器中Console中打印location,结果如下:
所以总结如下
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?username=admin&password=123#/write" --- 超链接
origin: "http://172.16.20.218:8080" --- 源
pathname: "/m/MGU20201126001-001/index.html" --- 路径名
port: "8080" --- 端口号
protocol: "http:" --- 协议
search: "?username=admin&password=123" --- 查询参数
总结之后就不用再去查询了,忘记了就直接在这里查阅了。