javascript - "#" or "#!" in vue-router
ringa_lee
ringa_lee 2017-06-12 09:29:49
0
4
1855

I don’t understand what “#” or “#!” means in vue routing
The routing in my demo has “#” http://localhost:8080/#/home/article
I saw "#!" in the vue route on the Internet https://mrjeff578575.github.io/Vue-demo/#!/home/article

ringa_lee
ringa_lee

ringa_lee

reply all(4)
typecho

Portal https://router.vuejs.org/zh-c...

Now there are 3 modes of front-end routing

  1. hash: Use URL hash value for routing. Supports all browsers, including browsers that don't support the HTML5 History API.

  2. history: Relies on HTML5 History API and server configuration. Check out HTML5 History mode.

  3. abstract: Supports all JavaScript runtime environments, such as Node.js server side. If no browser API is found, the router will automatically force into this mode.

The commonly used ones are 1 (the address has a # number) and 2 (the address is no different from the real request)


In addition,

# is the hash symbol used by vue-router

#! is the hash symbol used by angularjs Route

It doesn’t matter, just have # (the browser will not jump to the page)


You are using vue-router v0.7.13 for that page. I see that the source code also has the #! symbol

左手右手慢动作

Vue routing mode

This is called the routing hash strategy. The corresponding one is the path strategy. '#' is called the hash symbol. The path after the hash will not be parsed by the server. The specific search is done by yourself.

扔个三星炸死你

#! is a hashbang, which means exactly the same as #. The difference is only semantics.

过去多啦不再A梦

# is hash mode
history mode does not have # sign,
but if deployed to the server
hash mode will not cause refresh 404 problem. .
If you refresh or directly connect to a page in history mode, 404 will be prompted. . .
In the traditional way, the back-end program will actually generate a file, and the connection request can actually find a file. .
This single page only has one html, and the back-end program will not automatically generate the file. .
So if you use history mode, you need to configure the virtual path when deploying to the server
If the resource cannot be requested, it will point to the index.html file

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template