我在使用Ember App Kit访问DS.FixtureAdapter商店时遇到了一些麻烦。
我的app/adapters/application.coffee
ApplicationAdapter = DS.FixtureAdapter.extend
`export default ApplicationAdapter`
我的models/question.coffee
Question = DS.Model.extend
title: DS.attr 'string'
question: DS.attr 'string'
date: DS.attr 'date'
author: DS.attr 'string'
Question.reopenClass
FIXTURES: [
{
id: 101,
title: 'How do I feed hamsters?',
author: 'Tom Dale',
date: '2013-01-01T12:00:00',
question: 'Tomster cant eat using knife and a fork because his hands are \
too small. We are looking for a way to feed him. Any ideas?'
},
{
id: 102,
title: 'Are humans insane?',
author: 'Tomster the Hamster',
date: '2013-02-02T12:00:00',
question: 'I mean are totaly nuts? Is there any hope left for them? Should \
we hamsters try to save them?'
}
]
`export default Question`
我的app/routes/questions/index.coffee
QuestionIndexRoute = Ember.Route.extend
model: ->
@.store.findAll('question')
`export default QuestionIndexRoute`
现在,每当我尝试加载页面时,都会错误地显示TypeError: undefined is not a function
在Chrome中检查Ember Inspector Data标签,没有任何数据。即使我发表评论@.store.findAll('question')
,我仍然看不到任何内容。
把头发拉过来一段时间了。有人有什么建议吗?
编辑:
添加完整堆栈跟踪:
TypeError: undefined is not a function
at instantiate (http://localhost:8000/vendor/ember/ember.js:11333:26)
at lookup (http://localhost:8000/vendor/ember/ember.js:11199:19)
at Object.Container.lookup (http://localhost:8000/vendor/ember/ember.js:10878:16)
at Ember.Object.extend.adapterFor (http://localhost:8000/vendor/ember-data/ember-data.js:10109:78)
at Ember.Object.extend.fetchAll (http://localhost:8000/vendor/ember-data/ember-data.js:9417:28)
at Ember.Object.extend.findAll (http://localhost:8000/vendor/ember-data/ember-data.js:9406:21)
at Ember.Route.extend.model (http://localhost:8000/assets/app.js:149:27)
at superWrapper [as model] (http://localhost:8000/vendor/ember/ember.js:1239:16)
at Ember.Route.Ember.Object.extend.deserialize (http://localhost:8000/vendor/ember/ember.js:35901:19)
at http://localhost:8000/vendor/ember/ember.js:32521:57
答案 0 :(得分:0)
@.store.findAll('question')
应为@store.findAll('question')
答案 1 :(得分:0)
我很确定:
ApplicationAdapter = DS.FixtureAdapter.extend
应该是
ApplicationAdapter = DS.FixtureAdapter.extend()