简体   繁体   English

Webpack / jquery.ns-autogrow未捕获的TypeError:无法读取未定义的属性'fn'

[英]Webpack / jquery.ns-autogrow Uncaught TypeError: Cannot read property 'fn' of undefined

Hy there 你好

I'm new to Webpack or JS-bundel in general. 我是Webpack或JS-bundel的新手。 So this question might sound dumb. 因此,这个问题听起来可能很愚蠢。 If so, I'm sorry.. 如果是这样,对不起。

I'm using webpack to bundle all JS files. 我正在使用webpack捆绑所有JS文件。 So far I have this im main.js : 到目前为止,我有这个im main.js

var jQuery  = require('jquery');
var autogrow = require('jquery.ns-autogrow');

(function($){

    $(function(){
        $('textarea').autogrow();
    });

})(jQuery);

But now I get Uncaught TypeError: Cannot read property 'fn' of undefined right at the beginning of the ns-autogrow plugin/module. 但是现在我得到了Uncaught TypeError: Cannot read property 'fn' of undefined在ns-autogrow插件/模块的开头Uncaught TypeError: Cannot read property 'fn' of undefined

(function($, window) {
    return $.fn.autogrow = function(options) { ...

Is there something I made wrong requiring the dependencies? 我是否有错误要求依赖项?

You have to include jquery dependency at the global scope of your app to use it this way : 您必须在应用程序的全局范围内包含jquery依赖项才能以这种方式使用它:

(function($){

    $(function(){
        $('textarea').autogrow();
    });

})(jQuery);

To do it, you should use something like : 为此,您应该使用类似:

externals: {
    // require("jquery") is external and available
    //  on the global var jQuery
    "jquery": "jQuery"
}

you can see more details at this address 您可以在此地址查看更多详细信息

I hope it may help 希望对您有所帮助

暂无
暂无

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

相关问题 未捕获的TypeError:无法读取未定义的属性'fn' - Uncaught TypeError: Cannot read property 'fn' of undefined 未捕获的TypeError:无法读取未定义的属性'fn',电子2,角6? - Uncaught TypeError: Cannot read property 'fn' of undefined, electron 2, angular 6? 无法读取未定义/未捕获类型错误的属性“fn”:$(...).daterangepicker 不是函数 - Cannot read property 'fn' of undefined / Uncaught TypeError: $(...).daterangepicker is not a function Webpack Uncaught TypeError:无法读取未定义的属性“调用” - Webpack Uncaught TypeError: Cannot read property 'call' of undefined React / Webpack / Django-未捕获的TypeError:无法读取未定义的属性“ XXX” - React/Webpack/Django - Uncaught TypeError: Cannot read property 'XXX' of undefined 未捕获的类型错误:无法读取 __webpack_require__ 处未定义的属性“调用” - Uncaught TypeError: Cannot read property 'call' of undefined at __webpack_require__ 把手TypeError:无法读取未定义的属性'fn' - Handlebars TypeError: Cannot read property 'fn' of undefined Jest - TypeError:无法读取未定义的属性“fn” - Jest - TypeError: Cannot read property 'fn' of undefined 将 Bootstrap 添加到 Gatsby 会产生“未捕获的类型错误:无法读取未定义的属性‘fn’” - Adding Bootstrap to Gatsby produces "Uncaught TypeError: Cannot read property 'fn' of undefined" Django Admin StackedInline未加载添加其他模型,未捕获的TypeError:无法读取未定义的属性'fn' - Django Admin StackedInline Not Loading Add Another model, Uncaught TypeError: Cannot read property 'fn' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM