1. Intuitive distinction

  • There’s an ugly hash sign in the hash mode
  • In history mode, there is no introduction
  • Vue uses hash mode by default

2. A hash pattern

  • What is hash mode

Hashes, also known as anchors, are used to locate pages. The *#* at the end of the HASH URL is actually the same thing in the ID selector that makes the corresponding ID element visible. The corresponding hash value transformation is the hash and other characters after the URL.

  • The characteristics of

The Hashchange event is not triggered when the hash value changes. Means: No request is sent to the server, and the backend is not affected. So a hash change does not reload the page.

3. The history mode

  • What is history mode

History — Implemented by the new pushState() and replaceState() methods in the HTML5 History Interface. So you can put parameters and you can put specific objects in history mode.

  • The characteristics of

The methods in history can be used to change the browser’s history stack :go, back, forward.

4. Differences

  • Hash mode: Route modifies information in # and browser requests do not pass data in #.
  • History mode: Change the path. If the path is inconsistent with the backend URL, error 404 is displayed.