作者:不铃不铃铃不铃铃铃 | 来源:互联网 | 2022-12-06 19:10
我想在react应用程序中读取并打印当前URL。现在,我正在使用“ window.location.pathname”来读取URL,但想知道是否有更好的方法或某些反应方式来读取URL
1> Ashley Ferna..:
window.location.href
返回当前页面的href(URL)
window.location.hostname
返回虚拟主机的域名
window.location.pathname
返回当前页面的路径和文件名
window.location.protocol
返回使用的Web协议(http:或https :)