简体   繁体   中英

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. 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).

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.

It is called Hashbang and you can read more about it in the documentation:

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

Those are called Hashbang URLs. Generally anything that us after Hash #, is not another URL but it still belongs to the same HTML page. With increasing JS libraries and increasing capabilities of web browsers, now we can replace URLs using HTML5 history API.

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.

I suggest you to read more on hashbang URLs: Doing links like Twitter, Hash-Bang #! URL's

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM