下面是我用於從Web API獲取數據的代碼。但每次我嘗試檢索數據時,都會得到相同的錯誤:無法在ember.js中設置未定義或空引用的屬性'store'。TypeError:無法在ember.js中設置未定義或null引用的屬性'store'
/// <reference path="Lib/ember.js" />
/// <reference path="Lib/ember-data.js" />
var App = Ember.Application.create();
Ember.onerror = function(e) {
alert(e);
};
App.ApplicationAdapter = DS.RESTAdapter.extend({
namespace: 'api'
});
App.store = DS.Store.create({
adapter: App.ApplicationAdapter
});
App.Product = DS.Model.extend({
ID: DS.attr("int"),
Name: DS.attr('string'),
Category: DS.attr('string'),
});
App.ApplicationRoute = Ember.Route.extend({
model: function() {
{{debugger}}
var store1 = this.get("store")
var k = store1.find('product', 1)
return k;
}
});
你使用哪種版本Ember.js的的jsfiddle? –
Shimon,我正在使用最新版本的ember.js,ember-data.js –