window.history popState pushState

@ State of the object: an object's history record additional points can be null
@ Page Title: all current browsers do not support
@ optional url: url browser does not check whether there is, change only the url , url must be the same domain, not across domains

//history.pushState(state, title, urll),在页面中创建一个 history 实体。直接添加到历史记录中。
  history.pushState({page: 1}, "title 1", "?page=1");

In making the browser only action will trigger the event, such as the user clicks on the browser's back button (or Javascript code in the call history.back ())

  window.addEventListener('popstate', (event) => {
    console.log("location: " + document.location + ", state: " + JSON.stringify(event.state));
  });

Reproduced in: https: //www.jianshu.com/p/1b57e480885e

Guess you like

Origin blog.csdn.net/weixin_33713350/article/details/91288056