Vue gets the current page address

1. Vue gets the complete address of the current page: window.location.href

2. Obtain the previous fixed address: window.location.host

Detailed explanation about window.location:

  The window.location object can not only get the address (URL) of the current page, but also redirect the browser to a new page.

  Below, take http://www.xxxxxx.com:8000/test?id=123&username=xxx as an example to explain:

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

  2. window.location.protocol (protocol) - http:

  3. window.location.host (domain name + port) - www.xxxxxx.com:8000

  4. window.location.hostname (domain name) - www.xxxxxx.com

  5. window.location.port (port) - 8000

  6. window.location.pathname (path) - /test

  7. window.location.search (request parameter)—— ?id=123&username=xxx

  8. window.location.origin (url in front of the path) - http://www.xxxxxx.com:8000

Guess you like

Origin blog.csdn.net/weixin_58414196/article/details/126976492