gpt4 book ai didi

javascript - emberjs ember-cli - 如何删除 {{#each}} 的已弃用通知

转载 作者:行者123 更新时间:2023-11-28 00:21:33 26 4
gpt4 key购买 nike

这是使用ember-cli 0.2.3

(模型)todo.js

import DS from 'ember-data';

export default DS.Model.extend({
title: DS.attr('string'),
isCompleted: DS.attr('boolean')
}).reopenClass({
FIXTURES: [
{
id: 1,
title: "Complete Ember.js Tutorial",
isCompleted: false
},
{
id: 2,
title: "Checkout some more ember stuff",
isCompleted: true
},
{
id: 3,
title: "Solve world hunger (with Ember)",
isCompleted: false
}
]
});

在router.js

this.resource('todos', { path: '/' });

在 todos.js

export default Ember.Route.extend({
model: function() {
return this.store.find('todo');
}
});

在 todos.hbs

{{#each}}
//some code here using the model
{{/each}}

在开发者控制台中收到此通知:

DEPRECATION: Using the context switching form of {{each}} is deprecated. 
Please use the keyword form (`{{#each foo in bar}}`) instead

请提供有关删除弃用通知的实际每个代码的建议。

以下是我尝试过的代码:

1 - {{#each todo in todo}} //no error, but no data in todo list
2 - {{#each todo in controller.todo}} //no error, but no data in todo list
3 - {{#each todo in todos.todo}} //no error, but no data in todo list
4 - {{#each todo in todos}} //no error, but no data in todo list

谢谢您 - 任何帮助,干杯!

最佳答案

{{#each todo in model}}
<li>{{todo.title}}</li>
{{/each}}

关于javascript - emberjs ember-cli - 如何删除 {{#each}} 的已弃用通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29962447/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com