首页IT科技vue获取当前url地址(vue获取当前页面地址)

vue获取当前url地址(vue获取当前页面地址)

时间2025-05-04 13:03:06分类IT科技浏览3863
导读:1、vue获取当前页面完整地址:window.location.href...

1            、vue获取当前页面完整地址:window.location.href

2                 、获取前面固定地址:window.location.host

关于window.location的详解:

  window.location 对象不仅可以获得当前页面的地址 (URL)            ,还能够将浏览器重定向到新的页面           。

  下面                 ,以http://www.xxxxxx.com:8000/test?id=123&username=xxx为例来进行解释:

  1. window.location.href (当前url)—— http://www.xxxxxx.com:8000/test?id=123&username=xxx

  2. window.location.protocol(协议)—— http:

  3. window.location.host(域名 + 端口)—— www.xxxxxx.com:8000

  4. window.location.hostname(域名)—— www.xxxxxx.com

  5. window.location.port(端口)—— 8000

  6. window.location.pathname(路径)—— /test

  7. window.location.search (请求的参数)—— ?id=123&username=xxx

  8. window.location.origin(路径前面的url)——  http://www.xxxxxx.com:8000

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
phpcms怎么修改模板风格(phpcms后台路径怎么改) seo排名优化是什么意思(掌握SEO排名优化利器,助您网站飞速突破!)