vue routing mode history and hash

Foreword

vue routing mode (mode) is divided into two: url mode

  1. history: When placed into the production environment, the need for additional redirection configured on the server.
    • It can be accessed from the url you can look out
    • In addition, when you create a project is not a problem to ask you not to use this mode of history
    • Gives you the feeling is a separate address
    • history to be included in the probability is much larger than the hash
  2. the hash : no additional on-line configuration.

Compare

history:

  • When placed in the production environment, the need for additional redirection configured on the server.
  • Entering the corresponding page, directly behind the display / xxx
    Here Insert Picture Description

hash

  • No additional on-line configuration.
  • When entering the corresponding page, after more than a history mode #
    Here Insert Picture Description

Where modification?

In index.js folder inside your router inside
Here Insert Picture Description

The biggest difference:

Here we are with Baidu as an example

hash

When we enter the back of Baidu # a = 1 Enter

Here Insert Picture Description
We can see that the page has not changed


history

When we entered / one behind Baidu

Here Insert Picture Description
He will give you generate a new address

In the above people will default server to access your address has changed

Published 63 original articles · won praise 6 · views 1205

Guess you like

Origin blog.csdn.net/qq_44163269/article/details/105191927