我最近一直在学习 Ember,我一直在玩他们网站指南部分中的示例,但我遇到了以下片段的问题:
1) Javascript
App = Ember.Application.create();
App.Person = Ember.Object.extend({
firstName: null,
lastName: null,
fullName: function() {
return this.get('firstName') +
" " + this.get('lastName');
}.property('firstName', 'lastName')
});
App.ApplicationRoute = Ember.Route.extend({
model: function() {
var people = [
App.Person.create({
firstName: "Tom",
lastName: "Dale"
}),
App.Person.create({
firstName: "Yehuda",
lastName: "Katz"
})
];
return people;
}
});
2)HTML
<script type="text/x-handlebars">
<h1>People</h1>
<ul>
{{#each model}}
<li>Hello, <b>{{fullName}}</b>!</li>
{{/each}}
</ul>
</script>
当我导航到该网站时,它会按预期正确显示页面和名称。然后我导航到 localhost:80/#,它会复制模板,以便所有内容都显示两次。当我使用浏览器的箭头控件来回导航时,每次都会在页面底部附加/复制模板。
老实说,我不明白为什么会这样。想法?