Ember.js 使用Ember应用程序工具包获取夹具适配器时遇到问题
使用Ember App Kit访问DS.FixtureAdapter的应用商店时遇到问题 我的Ember.js 使用Ember应用程序工具包获取夹具适配器时遇到问题,ember.js,ember-data,Ember.js,Ember Data,使用Ember App Kit访问DS.FixtureAdapter的应用商店时遇到问题 我的app/adapters/application.coffee ApplicationAdapter = DS.FixtureAdapter.extend `export default ApplicationAdapter` Question = DS.Model.extend title: DS.attr 'string' question: DS.attr 'string' da
app/adapters/application.coffee
ApplicationAdapter = DS.FixtureAdapter.extend
`export default ApplicationAdapter`
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`
QuestionIndexRoute = Ember.Route.extend
model: ->
@.store.findAll('question')
`export default QuestionIndexRoute`
我的模型/问题.咖啡
ApplicationAdapter = DS.FixtureAdapter.extend
`export default ApplicationAdapter`
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`
QuestionIndexRoute = Ember.Route.extend
model: ->
@.store.findAll('question')
`export default QuestionIndexRoute`
我的应用程序/路线/问题/索引。咖啡
ApplicationAdapter = DS.FixtureAdapter.extend
`export default ApplicationAdapter`
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`
QuestionIndexRoute = Ember.Route.extend
model: ->
@.store.findAll('question')
`export default QuestionIndexRoute`
现在,每次我尝试加载页面时,它都会出错,出现TypeError:undefined不是一个函数
在检查灰烬检查器数据选项卡时,没有任何数据。即使我把@.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
@.store.findAll('question')
应该是@store.findAll('question')
我确信:
ApplicationAdapter=DS.FixtureAdapter.extend
应该是
ApplicationAdapter=DS.FixtureAdapter.extend()
@.store.findAll('question')
应该是@store.findAll('question')
您的问题模型在question.coffee
中的缩进也似乎关闭了,但这可能是因为粘贴到了SO中。您能指定哪一行引发了错误吗?@chopper-我尝试将其更改为`@store.findAll('question'),并得到了相同的问题。由于粘贴了代码,提示已关闭。。coffeescript通过jshint时没有任何问题。导致erorr的行是“@.store.findAll('question')行。如果我删除那一行并返回一个数组,页面的加载会很好。尝试了这一点,没有任何区别。我已经编辑了原始问题并添加到堆栈跟踪中,以防它给你带来任何想法。你能试着加入调试器吗?在控制台中,什么是this.store
和this.store.findAll('question')
返回?this.store类{typeMaps:Object,recordArrayManager:Class,_relationshipChanges:Object,_pendingSave:Array[0],u ember1395184210171:undefined…}this.store.findAll('question'))TypeError:undefined不是一个函数
你创建了商店吗?我的印象是你不需要在Ember App Kit下创建商店this.store
在调试器中不会导致错误,并且似乎返回了正确的类型