繁体   English   中英

jQuery错误使用npm安装bootstrap 4

[英]Jquery error installing bootstrap 4 with npm

我用npm安装了bootstrap 4。 我目前正在使用React库。 我正在为es2015传达不断上升的通天塔,并做出反应。 还使用webpack。 在控制台上,我收到有关jQuery的以下错误,并来自文件transition.js:

    Uncaught ReferenceError: jQuery is not defined       transition.js

这是webpack配置:

     const webpack = require('webpack');
     const path = require('path');
     const autoprefixer = require('autoprefixer');

     module.exports = {
entry: [
    "./client/main.js",
    "bootstrap-loader",

],
output: {
    path: './public',
    filename: "bundle.js",
    publicPath: '/'
},
devServer: {
    inline: true,
    contentBase: './public'
},
module: {
    loaders: [
        {
            test:/\.jsx?$/,
            exclude: /(node_modules|bower_components)/,
            loader: 'babel',
            query: {
                presets: ['react', 'es2015']
            }

        },
        { test: /\.css$/, loaders: [ 'style', 'css', 'postcss' ] },
        { test: /\.scss$/, loaders: [ 'style', 'css', 'postcss', 'sass' ] },
        { test: /bootstrap\/dist\/js\/umd\//, loader: 'imports?jQuery=jquery!./file.js' },
        { test: /\.(woff2?|ttf|eot|svg)$/, loader: 'url?limit=10000' },

    ]
},
postcss: [ autoprefixer ]

}

问题是我需要在Web Pack配置中使用他的以下几行

var webpack = require('webpack');
....
plugins: [
    new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery"
    })
],

在以下文章中找到了答案: 在webpack中管理jQuery插件依赖项

暂无
暂无

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

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