简体   繁体   English

为什么JS Fiddle给我错误`Uncaught TypeError:undefined不是function`?

[英]Why does JS Fiddle give me the error `Uncaught TypeError: undefined is not a function `?

I'm testing a Plupload script when I keep getting `Uncaught TypeError: undefined is not a function . 当我不断收到`Uncaught TypeError:undefined不是一个函数时,我正在测试Plupload脚本

Not able to figure out why, I tested with an example from jQuery . 无法弄清原因,我使用jQuery示例进行了测试。 I get the same error ( se fiddle ). 我收到相同的错误( se fiddle )。

Can anyone tell me why this isn't working? 谁能告诉我为什么这不起作用?

Code: 码:

$( "div" ).greenify({
  color: "orange"
});

(function ( $ ) {
    $.fn.greenify = function( options ) {
       // Do stuff here
    };
}( jQuery ));

Because you have those in the wrong order: 因为顺序错误,所以:

// First add the plugin
(function ( $ ) {
    $.fn.greenify = function( options ) {
       // Do stuff here
    };
}( jQuery ));

// THEN use it
$( "div" ).greenify({
  color: "orange"
});

Updated Fiddle 更新的小提琴

The general order of things is: 事物的一般顺序是:

  1. script tag for jQuery jQuery的script标签
  2. script tags for any plugins 任何插件的script标签
  3. script tag(s) for your code 您的代码的script标签

暂无
暂无

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

相关问题 为什么会出现错误“未捕获的TypeError:未定义不是函数”? - Why is there an error, “Uncaught TypeError: undefined is not a function”? 为什么会出现错误“未捕获的TypeError:未定义不是函数”? - Why is there an error, “Uncaught TypeError: undefined is not a function”? 为什么这个简单的 Angularjs 使用 syncfusion 会抛出错误 Uncaught TypeError: Cannot read property 'widget' of undefined - Why does this simple Angularjs using syncfusion throws me the error Uncaught TypeError: Cannot read property 'widget' of undefined 为什么我的ember测试给我TypeError:'undefined'不是函数? - Why do my ember tests give me TypeError: 'undefined' is not a function? 为什么 Javascript 给我一个未捕获的类型 null 错误? - Why does Javascript give me a uncaught type null error? 错误:未捕获的类型错误:未定义不是函数 - Error: Uncaught TypeError: undefined is not a function React.js:未被捕获的TypeError:undefined不是一个函数 - React.js : Uncaught TypeError: undefined is not a function Ember.js:未捕获的TypeError:未定义不是一个函数 - Ember.js: Uncaught TypeError: undefined is not a function 未捕获的TypeError:undefined不是函数 - typeahead.js - Uncaught TypeError: undefined is not a function - typeahead.js 未捕获的TypeError:undefined不是simplePagination.js中的函数 - Uncaught TypeError: undefined is not a function in simplePagination.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM