我试图在我的 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($);
});
我真的被困在这里,任何帮助将不胜感激