尝试将 require js 应用于我的代码时,我得到一个主干是未定义的错误。我读过网站上的其他文章说要使用 shim,但并没有解决问题。
助手/util.js:
require.config({
waitSeconds: 10,
paths: {
"jquery": "https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min",
"underscore": "http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.6/underscore-min",
"backbone": "http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min"
},
shim: {
jquery: {
exports: "$"
},
underscore: {
exports: '_'
},
backbone: {
deps: ["underscore","jquery"],
exports: "Backbone"
},
app: {
deps: ["backbone"],
exports: "App"
}
}
});
require(["Scripts/jquery.flip.min.js"]);
require(["Scripts/jquery-ui-1.10.2.custom.min.js"]);
require(["Scripts/RatingProviders.js"]);
主.js:
require(["helper/util"], function(App) {
//Models
TestProvider = Backbone.Model.extend({
defaults: {
ID: '',
Name: '',
},
initialize: function() {
this.ID= '';
this.Name= '';
}
});
});