使用webpack将数据从页面传递到另一个

问题描述

我已经搜索了一段时间,试图找出一些东西,但实际上并不能解决它,我是Web开发的新手,并且我使用的webpack有点复杂。我想要做的就是使用相同的index.js将数据从booking.html传递到booking-step.html。

这是我的webpack配置

module.exports = {
entry: ['babel-polyfill','./src/js/index.js'],output: {
    path: path.resolve(__dirname,'dist'),filename: 'js/bundle.js'
},devServer: {
    contentBase: './dist'
},plugins: [
    new HtmlWebpackPlugin({
        filename: 'index.html',template: './src/js/view/booking.html',chunks:[]
    }),new HtmlWebpackPlugin({
        filename: 'booking-step2.html',template: './src/js/view/booking-step2.html',new MiniCssExtractPlugin({
        filename: "bundle.css"
    })
],module: {
    rules: [
        {
            test: /\.js$/,exclude: /node_modules/,use: {
                loader: 'babel-loader'
            }
        },{
            test: /\.(sa|sc|c)ss$/,use: [
                {
                    // After all CSS loaders we use plugin to do his work.
                    // It gets all transformed CSS and extracts it into separate
                    // single bundled file
                    loader: MiniCssExtractPlugin.loader
                },{
                    loader: 'css-loader'
                },]
        },{
            test: /\.(png|jpe?g|gif|svg)$/,use: [
                {

                    loader: "file-loader",// In options we can set different things like format
                    // and directory to save
                    options: {
                        outputPath: 'images'
                    }
                }
            ]
        }
    ]
}

这是我的index.js文件

index code

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)