简体   繁体   English

谁能解释为什么(http:// localhost:3000 /#/ home)#出现在网址之间

[英]can anyone explain why (http://localhost:3000/#/home) # occurs inbetween the url

我是angular js和node js的新手,我有些怀疑,谁能解释为什么#出现在url(localhost:3000 /#/ home)之间

# in the URL segment denotes tag id used to automatically jump to that section in a long page. URL段中的#表示用于自动跳转到长页面中该部分的标签ID。 Now-a-days this is used by java-script frameworks like angular for virtual navigation purpose ie, changing the part after # does not cause a full page reload by the browser and used internally which div element to show/hide in a SPA(Single Page Applications). 如今,它已被java-script框架(例如angular)用于虚拟导航目的,即,在#之后更改部分不会导致浏览器重新加载整个页面,并在内部使用哪个div元素显示/隐藏在SPA(单页应用程序)。

It is a way for older browsers to not do a full reload of the page when you navigate in your single page application in AngularJS. 当您在AngularJS中浏览单页应用程序时,这是较旧的浏览器不完全重新加载页面的一种方法。

It is called Hashbang and you can read more about it in the documentation: 它称为Hashbang,您可以在文档中阅读有关它的更多信息:

https://docs.angularjs.org/guide/$location#hashbang-and-html5-modes https://docs.angularjs.org/guide/$location#hashbang-and-html5-modes

Those are called Hashbang URLs. 这些称为Hashbang URL。 Generally anything that us after Hash #, is not another URL but it still belongs to the same HTML page. 通常,我们在哈希号之后的所有内容都不是另一个URL,但它仍属于同一HTML页面。 With increasing JS libraries and increasing capabilities of web browsers, now we can replace URLs using HTML5 history API. 随着JS库的增加和Web浏览器功能的增加,现在我们可以使用HTML5历史API替换URL。

This hashbang technique is used as a fallback for older browsers, ie, the whole application runs on a single HTML page and Angular watches for any # hash changes in the URL and triggers the appropriate route controller. 该hashbang技术用作旧版浏览器的后备,即,整个应用程序在单个HTML页面上运行,并且Angular监视URL中的任何#哈希更改并触发适当的路由控制器。

I suggest you to read more on hashbang URLs: Doing links like Twitter, Hash-Bang #! 我建议您阅读有关hashbang URL的更多信息: 做Twitter,Hash-Bang等链接! URL's 网址

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 URL 地址从 localhost:3000/home 更改为 localhost:3000/home#_=_ - URL address changing from localhost:3000/home to localhost:3000/home#_=_ 当我尝试打开http:// localhost:3000 / pages / home时出错 - Error when I try to open http://localhost:3000/pages/home 从源 'http://localhost:3000' 在 'http://localhost:8080/home/data' 访问 XMLHttpRequest - Access to XMLHttpRequest at 'http://localhost:8080/home/data' from origin 'http://localhost:3000' 谁能解释为什么这个JavaScript无法运行 - Can anyone explain why this JavaScript wont run 任何人都可以解释为什么这不起作用? - Can anyone explain why this does not work? 为什么我不能在localhost:3000上查看我的Express应用程序 - Why can I not view my express app on localhost:3000 为什么我不能在反应中使用 axios 从 localhost:3000 调用 localhost localhost:5000 - Why can't I call localhost localhost:5000 from localhost:3000 using axios in react 我如何将 http post 请求从 localhost:5000 发送到 localhost:3000 - how can i send http post request from localhost:5000 to localhost:3000 任何人都可以在打字稿中解释 &lt;-&gt; - can anyone explain <-> in typescript XMLHttpRequest无法加载“此URL”来源Access:Control-Allow-Origin不允许使用原始http:// localhost:3000。 - XMLHttpRequest cannot load “THIS URL” Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM