e(...)。foundation不是Webpack基础6.4的功能

时间:2018-05-23 18:32:09

标签: javascript reactjs webpack zurb-foundation zurb-foundation-6

我是基金会6.4的新手。当我使用$(document).foundation();

时出错

以下是代码:

1.webpack.config.js



includes




  1. index.index
  2. 
    
    const webpack = require('webpack');
    
    module.exports = {
        entry: ['./src/index',
        'script-loader!jquery/dist/jquery.min.js',
        'script-loader!foundation-sites/dist/js/foundation.min.js'],
        mode: "production",
        output: {
            path: __dirname,
            filename: './public/bundle.js'
        },
        performance: {
            hints: false
        },
        plugins: [
            new webpack.ProvidePlugin({
                $: 'jquery',
                jQuery: 'jquery'
            })
        ],
        module: {
            rules: [
                {
                    test: /\.jsx$|\.js$/,
                    exclude: /node_modules/,
                    use: {
                        loader: "babel-loader",
                        options: {
                            presets: ['react','es2015'],
                        }
                    }
                },
            ]
        }
    };
    
    
    

    当我运行这个应用程序时,我在控制台中出错:未捕获TypeError:e(...)。foundation不是函数。

    任何人都可以帮助我^^。提前感谢:)

1 个答案:

答案 0 :(得分:1)

尝试导入jQuery并将其添加到窗口中:

import { Foundation } from 'foundation-sites';
import jquery from 'jquery';

window.jQuery = jquery;
window.$ = jquery;

Foundation.addToJquery($);

jQuery(document).ready($ => ($(document).foundation()));