Live2d Test Env

公共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'

 

posted @ 2019-12-04 17:32  小猪(朱)  阅读(581)  评论(0编辑  收藏  举报