BOM操作-2:location地址栏 / hash哈希 / h
2019-10-18 本文已影响0人
kino2046
location 地址: 地址栏相关的信息
host: "127.0.0.1" 主机信息 域名 + 端口
hostname: "localhost" 主机地址(IP地址) || 域名
href 完整的地址
port: 端口
pathname: 路径
protocol: "http"||"https" 协议
# hash 代表了 # 后边跟随的是hash
? search 代表了 ?后边跟随的内容, form表单中input提交的name值,如?wd=开课吧 (get方式提交过来的数据)
![](https://img.haomeiwen.com/i12421083/416d1d7e49145151.png)
hash # 后边跟随的是hash
路由(routing): 根据路径决定前端显示的视图
hashchange 监听 location 中的 hash 变化
hash路由实现原理
![](https://img.haomeiwen.com/i12421083/5131e48e2ae0f08d.png)
href 完整的地址栏信息
![](https://img.haomeiwen.com/i12421083/870f4935a05ee76f.png)
replace 替换地址栏信息
![](https://img.haomeiwen.com/i12421083/3cccdb57ea2d3762.png)
reload 刷新
![](https://img.haomeiwen.com/i12421083/3850719ed8927510.png)