我是基金会6.4的新手。当我使用$(document).foundation();
时出错以下是代码:
1.webpack.config.js
includes

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不是函数。
任何人都可以帮助我^^。提前感谢:)
答案 0 :(得分:1)
尝试导入jQuery并将其添加到窗口中:
import { Foundation } from 'foundation-sites';
import jquery from 'jquery';
window.jQuery = jquery;
window.$ = jquery;
Foundation.addToJquery($);
jQuery(document).ready($ => ($(document).foundation()));