我來自ruby/rails背景,所以我在圍繞UDEMY的骨幹課程練習中纏繞一些麻煩。有人可以告訴我我是否犯了錯誤,如果有的話如何解決?這次演習是關於收藏和我需要的輸出是console.logs學習backbone.js。我正確處理集合嗎?
var Vehicle = Backbone.Model.extend({
default: {
registrationNumber: "XXX-XXX",
color: "beige"
}
urlRoot: "/api/vehicle",
start: function(){
console.log("Vehicle started");
}
});
var Vehicles = Backbone.Collection.extend({
model: Vehicle,
url:"api/vehicles"
});
var vehicles = new Vehicles([
new Vehicle({car1: {registrationNumber = "XLI887", color = "Blue"} }),
new Vehicle({car2: {registrationNumber = "ZNP123", color = "Blue"}}),
new Vehicle({car3: {registrationNumber = "XUV456", color = "Grey"}})
]);
var blueCars = vehicles.where({ color: "Blue"});
var specificRegistration = vehicles.where({ registrationNumber:"XLI887"});
console.log("blue cars:", blueCars);
console.log("Registration #:", specificRegistration);
console.log("to JSON:", vehicles.toJSON());
這將是一個小如果您以文本形式提供代碼而不是截屏,則可以更容易地爲代碼提供提示。 =) –
我是相當新的stackoverflow。是否有一個捷徑來縮進網站上的整個代碼塊4空格?如果是的話,我將編輯... – Chris
你可以在編輯器中添加縮進,並從它粘貼到stackoverflow –