Home  >  Q&A  >  body text

javascript - Why can hash be used for route jumps but not refresh the page?

What is the principle of hash

This is not about the principle of implementing hash routing. I know how to implement it. What I want to know is why hash can be done

过去多啦不再A梦过去多啦不再A梦2685 days ago949

reply all(5)I'll reply

  • 巴扎黑

    巴扎黑2017-06-13 09:26:20

    Just follow the http protocol...

    reply
    0
  • 迷茫

    迷茫2017-06-13 09:26:20

    The principle is that the modification of the hash will not cause the browser to refresh. This is the most fundamental reason. If there are other attributes modified on the URL, it will not cause a refresh. It can also be used for routing. It’s that simple

    reply
    0
  • 大家讲道理

    大家讲道理2017-06-13 09:26:20

    This is originally the anchor information within the page, used for jumping within the page, such as Baidu Encyclopedia. The content behind the link description
    # represents the id of the anchor point. When this information exists, it will jump to the anchor point specified on the page. If you look at the Dom structure, you can see the following

    ps://wapbaike.baidu.com/item/http/243074?adapt=1&fr=aladdin#u0

    reply
    0
  • 代言

    代言2017-06-13 09:26:20

    It started out as an anchor point and was used as a non-refresh jump

    reply
    0
  • PHP中文网

    PHP中文网2017-06-13 09:26:20

    The advantage of this is that it can implement front-end routing, refer to /a/11... As for why it can be achieved, it is because the internal design of the browser is like this. Modify the hash and the browser will not jump.

    reply
    0
  • Cancelreply