Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.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 如何使用类似于jquery$.load()的Webpack4加载页面内容_Javascript_Jquery_Webpack - Fatal编程技术网

Javascript 如何使用类似于jquery$.load()的Webpack4加载页面内容

Javascript 如何使用类似于jquery$.load()的Webpack4加载页面内容,javascript,jquery,webpack,Javascript,Jquery,Webpack,我在webpack4内容加载方面遇到了一个问题,我以前是如何处理jquery的 下面是我试图用webpack4 假设我有一个页面setting.html <link rel="stylesheet" href="setting.css"> <div id="settingContent"> <!-- content --> </div> <script src="setting.js"></script> 使用jq

我在
webpack4
内容加载方面遇到了一个问题,我以前是如何处理
jquery

下面是我试图用
webpack4

假设我有一个页面
setting.html

<link rel="stylesheet" href="setting.css">
<div id="settingContent">
    <!-- content -->
</div>
<script src="setting.js"></script>
使用jquery时,我通常会这样做,如下所示

$('setting_tab').on('click',function(){
    $('#pageContent').load('setting.html');
});
下面是我的网页配置文件

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

    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/index.html'
            })
        ],
        module: {
            rules: [
                {
                    test: /\.js$/,
                    exclude: /node_modules/,
                    use: {
                        loader: 'babel-loader'
                    }
                }
            ]
        }
    };

webpack
不应该这样做
webpack
不应该这样做
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

    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/index.html'
            })
        ],
        module: {
            rules: [
                {
                    test: /\.js$/,
                    exclude: /node_modules/,
                    use: {
                        loader: 'babel-loader'
                    }
                }
            ]
        }
    };