繁体   English   中英

如何在 webpack 中将 init 添加到 es6 模块

[英]How add init to es6 modules in webpack

我正在使用 webpack 和 es6。

我在网页Barba.js 中page-transition

我必须用 Barba Event Barba newPageReady Event 重新初始化我的代码,我有很多独立的模块,比如menuEvent.jsparallaxEvent.jsinviewEvent.jstouchEvents.jsplugins and librarys.js touchEvents.js这些模块被导入到mainFile.js

重新初始化代码

我不知道如何将init添加到每个模块并在 Barba 事件中添加初始化脚本...

解决方案:

菜单事件js:

export class menuEvent {
    static init() {
        //codes
    }
}

巴尔巴:

import { menuEvent } from './menuEvent'

Barba.Dispatcher.on('newPageReady', function(currentStatus, oldStatus, container)    {
    menuEvent.init()
}); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM