What is the principle that vue-router changes mode:'hash' to mode:'history' and jumps abnormally?

clipboard.png

as in the routing configuration above, there is no server, and it starts locally. In the case of mode:"hash", the routed access will enter the corresponding component. In the case of mode:"history", however, no matter which route is accessed, it only jumps to the first HelloWorld component, not the corresponding component. What is the reason for this?

Feb.28,2021

1. When using hash mode, the principle is to add the-sharp number after your address, and then add the address after the-sharp number to jump. In fact, it is the vue-router plug-in that detects your hash value and then renders the specified component based on your hash value.
2, when you change to history. In fact, the real address should appear on the address bar. That is, when you want to access another address, you need to remove the-sharp number. By default, something after the-sharp sign is not treated as a new request (that is, the value after hash is considered by the server to be the same page). This, and when you are learning html, click on the anchor link, or not refresh on this page is the same reason, but when you click the a tag without-sharp, the link will really jump to the same reason.
3. To get back to the point, if you want to jump, please make sure that url does not have any-sharp number in history mode. That is, it is assumed that the port opened by the landlord's cli is 8080.
then jumping to login should be http://localhost:8080/login

.
Menu