vue disable the browser return function

 1 // 引入jq
 2 mounted() { // 看好周期
 3     disableBrowserBack();
 4     history.pushState(null, null, document.URL);
 5     if (window.history && window.history.pushState) {
 6         $(window).on('popstate', function () 
 7             window.history.pushState('forward', null, '');
 8             window.history.forward(1);
 9         });
10     }
11     //
12     window.history.pushState ( 'Forward', null , '');   // have to have two lines in IE 
13 is      window.history.forward (. 1 );
 14 },

 

Or mentioned in public js

util.js

 1 import "@/xb-share/api/jquery-1.11.3.min.js";
 2  
 3 export const disableBrowserBack = (param) => {
 4     return (function () {
 5         history.pushState(null, null, document.URL);
 6         if (window.history && window.history.pushState) {
 7             $(window).on('popstate', function () {
 8                 window.history.pushState('forward', null, '');
 9                 window.history.forward(1);
10             });
11         }
12         //
13         window.history.pushState('forward', null, '');
14         window.history.forward(1);
15     })()
16 };

Page references

1 import {disableBrowserBack} from "../../xb-share/util/util";
2 
3 
4 mounted() {
5     disableBrowserBack()
6 },

On it

Guess you like

Origin www.cnblogs.com/xiaozhu-zhu/p/11984056.html