Ember CLI - 夹具数据未显示
Ember CLI - Fixture data not displaying
我正在按照本指南进行操作http://emberjs.com/guides/models/the-fixture-adapter/
我只是想在 personality 资源路径中显示我的灯具数据列表。我做错了什么?
浏览器控制台错误为:
Error while processing route: personality.index attr is not defined ReferenceError: attr is not defined
当我尝试在我的路线中获取模型时,模板不再呈现。
routes/personalities.咖啡
`import Ember from 'ember'`
PersonalitiesRoute = Ember.Route.extend
model: ->
this.get(store).find('personality')
`export default PersonalitiesRoute`
以上是破坏应用程序的代码部分(编译,但不显示任何内容)。我究竟做错了什么?
我的适配器、模板和模型如下
我确保使用了夹具适配器
adapters/application.咖啡
`import DS from 'ember-data'`
ApplicationAdapter = DS.FixtureAdapter.extend()
`export default ApplicationAdapter`
adapters/personalities.咖啡
`import ApplicationAdapter from './application'`
PersonalitiesAdapter = ApplicationAdapter.extend()
#I also tried... = DS.FixtureAdapter.extend()
#I also tried getting rid of PersonalitiesAdapter
#I also tried PersonalityAdapter (singular, since that matches the model, which is singular)
`export default PersonalitiesAdapter`
我也尝试过使用我能想到的各种个性化适配器设置,但都无济于事。
models/personality.咖啡
`import DS from 'ember-data'`
Personality = DS.Model.extend
id: attr('number')
type: attr('string')
socType: attr('string')
Personality.reopenClass
FIXTURES: [
{ id: 1, type: 'entp', socType: 'NLE' }
{ id: 2, type: 'isfp', socType: 'SFI' }
{ id: 3, type: 'esfj', socType: 'ESE' }
{ id: 4, type: 'intj', socType: 'LII' }
{ id: 5, type: 'enfj', socType: 'EIE' }
{ id: 6, type: 'istj', socType: 'LSI' }
{ id: 7, type: 'estp', socType: 'SLE' }
{ id: 8, type: 'infp', socType: 'IEI' }
{ id: 9, type: 'esfp', socType: 'SEE' }
{ id: 10, type: 'intp', socType: 'ILI' }
{ id: 11, type: 'entj', socType: 'LIE' }
{ id: 12, type: 'isfj', socType: 'ESI' }
{ id: 13, type: 'estj', socType: 'LSE' }
{ id: 14, type: 'infj', socType: 'FII' }
{ id: 15, type: 'enfp', socType: 'NEE' }
{ id: 16, type: 'istp', socType: 'SLI' }
]
`export default Personality`
templates/personalities.会徽
= each item in model
= item.id
= item.type
= item.socType
= item.description
Personality = DS.Model.extend
id: attr('number')
type: attr('string')
socType: attr('string')
应该是
Personality = DS.Model.extend
id: DS.attr('number')
type: DS.attr('string')
socType: DS.attr('string')
我正在按照本指南进行操作http://emberjs.com/guides/models/the-fixture-adapter/
我只是想在 personality 资源路径中显示我的灯具数据列表。我做错了什么?
浏览器控制台错误为:
Error while processing route: personality.index attr is not defined ReferenceError: attr is not defined
当我尝试在我的路线中获取模型时,模板不再呈现。
routes/personalities.咖啡
`import Ember from 'ember'`
PersonalitiesRoute = Ember.Route.extend
model: ->
this.get(store).find('personality')
`export default PersonalitiesRoute`
以上是破坏应用程序的代码部分(编译,但不显示任何内容)。我究竟做错了什么?
我的适配器、模板和模型如下
我确保使用了夹具适配器 adapters/application.咖啡
`import DS from 'ember-data'`
ApplicationAdapter = DS.FixtureAdapter.extend()
`export default ApplicationAdapter`
adapters/personalities.咖啡
`import ApplicationAdapter from './application'`
PersonalitiesAdapter = ApplicationAdapter.extend()
#I also tried... = DS.FixtureAdapter.extend()
#I also tried getting rid of PersonalitiesAdapter
#I also tried PersonalityAdapter (singular, since that matches the model, which is singular)
`export default PersonalitiesAdapter`
我也尝试过使用我能想到的各种个性化适配器设置,但都无济于事。
models/personality.咖啡
`import DS from 'ember-data'`
Personality = DS.Model.extend
id: attr('number')
type: attr('string')
socType: attr('string')
Personality.reopenClass
FIXTURES: [
{ id: 1, type: 'entp', socType: 'NLE' }
{ id: 2, type: 'isfp', socType: 'SFI' }
{ id: 3, type: 'esfj', socType: 'ESE' }
{ id: 4, type: 'intj', socType: 'LII' }
{ id: 5, type: 'enfj', socType: 'EIE' }
{ id: 6, type: 'istj', socType: 'LSI' }
{ id: 7, type: 'estp', socType: 'SLE' }
{ id: 8, type: 'infp', socType: 'IEI' }
{ id: 9, type: 'esfp', socType: 'SEE' }
{ id: 10, type: 'intp', socType: 'ILI' }
{ id: 11, type: 'entj', socType: 'LIE' }
{ id: 12, type: 'isfj', socType: 'ESI' }
{ id: 13, type: 'estj', socType: 'LSE' }
{ id: 14, type: 'infj', socType: 'FII' }
{ id: 15, type: 'enfp', socType: 'NEE' }
{ id: 16, type: 'istp', socType: 'SLI' }
]
`export default Personality`
templates/personalities.会徽
= each item in model
= item.id
= item.type
= item.socType
= item.description
Personality = DS.Model.extend
id: attr('number')
type: attr('string')
socType: attr('string')
应该是
Personality = DS.Model.extend
id: DS.attr('number')
type: DS.attr('string')
socType: DS.attr('string')