Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在另一个类的构造函数中使用导入的类_Javascript_Ecmascript 6_Babeljs - Fatal编程技术网

Javascript 在另一个类的构造函数中使用导入的类

Javascript 在另一个类的构造函数中使用导入的类,javascript,ecmascript-6,babeljs,Javascript,Ecmascript 6,Babeljs,从ES6语法开始,为什么mesagester.Create(“bar”)在主系统中失败 我在src/app.js中有以下内容(这也是网页条目): 在另一个文件中,src/helpers/MessageTester.js,我有以下内容: class MessageTester { constructor(msg) { document.querySelector('#root').innerHTML = `<p>` + msg + `</p>`;

从ES6语法开始,为什么
mesagester.Create(“bar”)在主系统中失败

我在src/app.js中有以下内容(这也是网页条目):

在另一个文件中,src/helpers/MessageTester.js,我有以下内容:

class MessageTester {
    constructor(msg) {
        document.querySelector('#root').innerHTML = `<p>` + msg + `</p>`;
    }

    static Create(msg) {
        return new MessageTester(msg);
    }
}

export {MessageTester};
缺失的s

MessageTester.Create("bar");

英雄联盟谢谢有趣的是,我如此确信它是网页配置中的某个东西,因为我几乎是在复制/粘贴,所以它让我怀疑自己;)非常感谢!
// webpack.config.js
const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');

const config = {
    context: path.resolve(__dirname, 'src'),
    entry: {
        jistudio: './app.js'
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name].bundle.js',
        sourceMapFilename: '[name].map',
        chunkFilename: '[id].chunk.js'
    },
    module: {
        rules: [{
            test: /\.js$/,
            include: path.resolve(__dirname, 'src'),
            use: [{
                loader: 'babel-loader',
                options: {
                    presets: [
                        ['es2015', {modules: false}]
                    ]
                }
            }]
        }]
    },
    devtool: 'eval-source-map',
    plugins: [
        new HtmlWebpackPlugin({
            template: './index.html',
            chunksSortMode: 'dependency'
        }),
        new CopyWebpackPlugin([
            {
                from: path.resolve(__dirname, 'assets'),
            }
        ]),
        new webpack.optimize.UglifyJsPlugin({sourceMap: true})
    ],
    devServer: {
        contentBase: path.join(__dirname, "dist"),
        compress: true,
        port: 3000
    }
}

module.exports = config
MessageTester.Create("bar");