Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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
Jquery 网页包:未捕获引用错误:未定义复数_Jquery_Webpack_Webpack 2 - Fatal编程技术网

Jquery 网页包:未捕获引用错误:未定义复数

Jquery 网页包:未捕获引用错误:未定义复数,jquery,webpack,webpack-2,Jquery,Webpack,Webpack 2,我正在为我的项目使用webpack3.2.0和jquery2.1.1 这是我的webpack.config.js const path = require('path'); var webpack = require('/usr/local/lib/node_modules/webpack'); config = { // define entry point entry: "./src/index.js", // define output point ou

我正在为我的项目使用
webpack3.2.0
jquery2.1.1

这是我的
webpack.config.js

const path = require('path');
var webpack = require('/usr/local/lib/node_modules/webpack');

config = {
    // define entry point
    entry: "./src/index.js",

    // define output point
    output: {
        path: path.resolve(__dirname, ''), // no need to create folder
        filename: 'bundle.js'
    },
    module: {
      rules: [{
              test: require.resolve('./jquery.min.js'),
              use: [{
                  loader: 'expose-loader',
                  options: 'jQuery'
              },{
                  loader: 'expose-loader',
                  options: '$'
              }]
          }]
    }
};

module.exports = config;
我的javascript文件片段

function plural(s) {
    "use strict";
    return s + 's';
}
但它在web浏览器中给出了以下错误

(index):672 Uncaught ReferenceError: plural is not defined
    at buildPageElements ((index):672)
    at finishInitialization ((index):5113)
    at Object.<anonymous> ((index):5142)
    at j (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at x (jquery.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery.min.js:4)
(索引):672未捕获引用错误:未定义复数
在buildPageElements((索引):672)
完成初始化时((索引):5113)
反对。((索引):5142)
在j(jquery.min.js:2)
在Object.fireWith[as resolveWith](jquery.min.js:2)
在x(jquery.min.js:4)
在XMLHttpRequest。(jquery.min.js:4)
如果我添加
window.plural=plural
,那么它工作正常


有什么解决方案我不必在我的javascript文件中使用
window.plural=plural
,你在哪里/如何将
plural
导入到使用它的模块中?(你知道这比在单词末尾添加
s
要复杂得多…?)这是我的javascript文件的一个功能。我得到的不是所有函数的定义错误。再次说明:您在哪里/如何将
复数
导入到您得到该错误的模块中?如果您试图在与该声明或嵌套范围相同的范围内使用它,那么肯定不会在同一个模块中得到它。我们无法帮助您处理无法看到的代码。请用演示该问题的示例更新您的问题。
function plural(s) {
    "use strict";
    return s + 's';
}