[英]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.