如何在Webpack中的ES6模块中添加初始化

时间:2018-08-21 14:52:53

标签: javascript webpack ecmascript-6 module init

我正在使用webpack和es6。

我在网页Barba.js中有> x <- matrix(replicate(9,1), ncol = 3, nrow = 3) > x [,1] [,2] [,3] [1,] 1 1 1 [2,] 1 1 1 [3,] 1 1 1 > tr(x) [1] 3 > x <- matrix(replicate(12,1), ncol = 4, nrow = 3) > x [,1] [,2] [,3] [,4] [1,] 1 1 1 1 [2,] 1 1 1 1 [3,] 1 1 1 1 > tr(x) Fehler in tr(x) : m must be a square matrix

我必须使用Barba事件Barba newPageReady Event重新初始化代码,我有许多单独的模块,例如"use strict"; const winston = require('winston'); const myFormat = winston.format.printf(info => { return `${info.timestamp} ${info.level}: ${info.message}`; }); const logger = winston.createLogger({ level: "debug", format: winston.format.combine(winston.format.timestamp(), myFormat), // winston.format.json(), transports: [ new winston.transports.File({filename: "logs/error.log", level: 'error'}), new winston.transports.File({filename: 'logs/combined.log'}), ], exceptionHandlers: [ new winston.transports.File({ filename: 'logs/exceptions.log' }), new winston.transports.File({ filename: 'logs/combined.log' }) ], exitOnError: false, // handleExceptions: true // Otherwise, you should use this in options. }); process.on('unhandledRejection', (reason, promise) => { logger.debug(reason); }); process.on('uncaughtException', (err) => { logger.debug(err); }); page-transitionmenuEvent.jsparallaxEvent.js,{{1 }}这些模块将导入到inviewEvent.js

Reinit Code

我不知道如何在每个模块中添加touchEvents.js并在Barba Event中添加初始化脚本...

1 个答案:

答案 0 :(得分:0)

解决方案:

  

menuEventjs:

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

Barba:

import { menuEvent } from './menuEvent'

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