How to change the url of the browser, but not let the page refresh. url form and HTML5 history mode

1. url form

1.1. The hash of the URL is location.hash='/foo'

insert image description here

2. HTML5 history mode

2.1、history.pushState({}, ’ ’ , ‘/’)

Equivalent to a stack.

The browser saves the history and can go back.
insert image description here

2.2、replaceState({}, ’ ', ‘/’)

The browser will not save the history and cannot return to the previous page.

insert image description here

2.3、history.go()

history.go(-1) goes one step back. Equivalent to history.back()
history.go(1) one step forward. Equivalent to) history.forward()
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/qq_46112274/article/details/123049566