0

我试图在我的 Marionette 应用程序中切换到 Zepto,并且我正在尝试使用这个 zepto 插件(https://github.com/sudhirj/simply-deferred)来支持 jquery deferred。我也在使用require.js,到目前为止还不能让它工作,我仍然得到这个错误:

Uncaught TypeError: Object function (selector, context){
    return zepto.init(selector, context)
  } has no method 'Deferred' 

这就是我需要的 js 文件的样子:

require.config({
  paths: {
    'backbone': 'lib/backbone',
    'text': 'lib/text',
    'underscore': 'lib/underscore',
    'bootstrap' : 'lib/bootstrap',
    'marionette' : 'lib/backbone.marionette',
    'localStorage' : 'lib/backbone.localStorage',
    'less' : 'lib/less',
    'Email' : 'models/email',
    "Emails" : 'collections/emails',
    "FormView" : 'views/FormView',
    "EmailsView" : 'views/EmailsView',
    "EmailView" : 'views/EmailView',
    "NoEmailView" : 'views/NoEmailView',
    "FormView" : 'views/FormView',
    "MyApp" : 'app',
    "parseEmail" :  "parsing/parseEmail",
    "LabelView" : "views/LabelView",
    'socketio': '../socket.io/socket.io',
    "zepto" : 'lib/zepto',
    "deferred" : 'lib/deferred'
  },
  shim: {
    'zepto':{
        deps: ["deferred"],
        exports: '$'
    },
    'underscore': {
      exports: '_'
    },
    'backbone': {
      deps: ["underscore", "zepto"],
      exports: 'Backbone'
    },
    'bootstrap' : {
        deps: ["zepto"]
    },
    'marionette' : {
      deps : ["backbone", "underscore", "zepto"],
      exports: 'Marionette'
    }
    'socketio': {
      exports: 'io'
    },
    },
});

require(

  [ "zepto",
    "underscore",
    "backbone",
    "less",
    "marionette",
    "MyApp",
    "socketio",
    "deferred",
  ],
  function($ , _, Backbone, less, Marionette, MyApp, io, Deferred) {
    Deferred.installInto($);

  });

我真的被困在这里,任何帮助将不胜感激

4

2 回答 2

1

我认为 deferred 应该取决于 Zepto,而不是相反:

shim: {
  'zepto':{
      exports: '$'
  },
  'deferred': {
      deps: ["zepto"],
  },
于 2013-09-27T04:49:45.137 回答
0

我认为“延期”可能还需要一个出口声明,以下对我有用..

  'deferred': {
    'deps': ['jquery'],
    'exports': 'Deferred'
  },
于 2013-11-12T09:39:06.390 回答