公共js文件return一个方法写法
公共js:
1 export const disableBrowserBack = (param) => { 2 return (function () { 3 history.pushState(null, null, document.URL); 4 if (window.history && window.history.pushState) { 5 $(window).on('popstate', function () { 6 window.history.pushState('forward', null, ''); 7 window.history.forward(1); 8 }); 9 } 10 // 11 window.history.pushState('forward', null, ''); 12 window.history.forward(1); 13 })() 14 };
页面引入使用:
import {disableBrowserBack} from '../../util/util'