當我嘗試將require js應用到我的代碼時,我得到的骨幹是undefined錯誤。我已閱讀網站上的其他文章,聲稱使用墊片並沒有解決問題。要求js和骨幹
幫手/ 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"]);
main.js:
require(["helper/util"], function(App) {
//Models
TestProvider = Backbone.Model.extend({
defaults: {
ID: '',
Name: '',
},
initialize: function() {
this.ID= '';
this.Name= '';
}
});
});
那麼,helper/util.js文件的內容會很有幫助。 – Loamhoof