【问题标题】:Loading Jquery plugin through RequireJS通过 RequireJS 加载 Jquery 插件
【发布时间】:2014-10-06 17:40:30
【问题描述】:

我在一个项目中使用了 requirejs,一切运行顺利。直到我不得不在我的项目中添加一个名为“elastislide”的 jquery 插件。我正在使用 shim 配置来指定插件对 jquery 和 jquery++ 的依赖关系。如下所示:

requirejs.config({
paths: {
    jquery: 'libs/jquery',
    jquerymobile: 'libs/jquery-mobile/jquery.mobile',
    underscore: 'libs/underscore',
    jquerypp: 'libs/jquerypp',
    elastislide: '../js/elastislide',
    app: '../js/app',
    model: '../js/app/model',
    view: '../js/app/view',
    controller: '../js/app/controller',

    shim: {
        'elastislide': {
            deps: ['jquery', 'jquerypp']
        }
    }
  }
});

在我的应用入口点我有这个:

define([
'jquery',
'jquerymobile',
'jquerypp/event/swipe',
'elastislide',
'model',
'view',
'controller'


], function ($, mobile, jqpp, elastislide, model, view, controller) {
//

而且我不断收到错误消息:“未捕获的 ReferenceError:未定义 jQuery”。我已经修改了 requirejs 文档并且看不到错误。谁能指点解决办法?

这是插件的网站:http://tympanus.net/codrops/2011/09/12/elastislide-responsive-carousel/

提前致谢!

【问题讨论】:

    标签: javascript jquery requirejs


    【解决方案1】:

    你可以换这个试试..

    deps: ['jquery, jquerypp']
    

    deps: ['jquery',  'jquerypp']
    

    根据 Require.js 文档,deps 接受数组...

    【讨论】:

    • 它仍然不起作用...现在我用这个更改编辑了问题。
    猜你喜欢
    • 1970-01-01
    • 2015-04-21
    • 2014-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多