vue jump page components, to achieve click on the browser comes back arrow to return to the previous page, instead of returning trail routes

// This method is click click to add a page to jump to add 
handleAdd (Val) { the let = _that the this; the let the callback = function () { _that.isAdd to false = window.removeEventListener ( "the popstate", the callback); }; History. to pushState (null, null, "/ More / basicInfo / HosData # Detail"); window.addEventListener ( "the popstate", the callback); this.isAdd = to true; },

removeEventListener () method is used to remove the  addEventListener ()  event handler method to add

popstate browser returns the event

When the activity history entry changes will trigger popstate event. If the history entry is activated by a call to history.pushState () created, or affected to history.replaceState () call, a copy of the state of the object of state property popstate events include historical items.

Note that the call history.pushState () or history.replaceState () does not trigger popstate event. 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 ())

Guess you like

Origin www.cnblogs.com/lvlvlv/p/11543909.html