我是新來的燼,似乎無法弄清楚爲什麼我的列表不會顯示。這裏是我的路線頁面上創建模型的代碼:不顯示模型信息
import Ember from 'ember';
export default Ember.Route.extend({
model: function(){
return ['Ford', 'tesla','lexus'];
}
});
,這是我的模板頁面
<h1>Cars</h1>
<ul>
{{#each car in model}}
<li>{{car}}</li>
{{/each}}
</ul>
但出於某種原因正在顯示任何信息。有人注意到我沒有看到的東西嗎?提前致謝!
<p>
<strong>authors: </strong>
{{#each authors}}
{{this}},
{{/each}}
</p>
<h4>Comments</h4>
<ul>
{{#each comments as comment}}
<li><strong>{{name}}</strong> - {{comment}}</li>
{{/each}}
</ul>
和
export default Ember.Controller.extend({
action:{
sayHello: function(){
alert('Hello')
},
toggleBody: function(){
this.toggleProperty('isShowingBody');
},
submitAction: function(){
alert(this.get('name'));
alert(this.get('comment'));
}
},
title: 'My Bliog Post',
body: 'My body of work is endless i tell you',
authors: ['william','robert','michelle'],
created: new Date(),
comments: [
{
name: 'Evan',
comment: 'Hey what is new '
},{
name: 'Evan',
comment: 'Hey ith you'
},{
name: 'Evan',
comment: 'Hey what is n'
}
]
});
按照燼指南。 https://guides.emberjs.com/v2.14.0/templates/displaying-a-list-of-items/我認爲你使用的語法是在舊版本的ember中使用的。多數民衆贊成已棄用,現在刪除 – kumkanillam