Ember.js 余烬:未处理任何操作错误
因此,我正在按照一个教程在CodeSchool上构建一个应用程序,当时我正试图找出如何编写切换,这时我注意到控制台中的一个错误,基本上是说没有任何东西在处理我在模板中编写的动作块Ember.js 余烬:未处理任何操作错误,ember.js,Ember.js,因此,我正在按照一个教程在CodeSchool上构建一个应用程序,当时我正试图找出如何编写切换,这时我注意到控制台中的一个错误,基本上是说没有任何东西在处理我在模板中编写的动作块 "Nothing handled the action 'toggleOption model option'. If you did handle the action, this error can be caused by returning true from an action handler in a co
"Nothing handled the action 'toggleOption model option'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble."
下面的代码是我遇到问题的模板部分
<ul class='list list--answer'>
{{#each model.poll.option as |option|}}
<li class='list-item'>
<button class='list-item-checkbox {{if (eq model.option option) "is-selected"}}' {{action "toggleOption model option"}}>
<b class='srt'>Select</b>
</button>
<span>{{option.label}}</span>
</li>
{{/each}}
</ul>
不管怎么说,我有什么遗漏吗?我已经盯着这个看了一段时间了,我想不出来。我一直在关注的教程视频和他们完成的代码似乎也没有遇到这个问题 有语法问题
{{action“toggleOption”model option}
应该是{{action“toggleOption”model option}
我只是拍了拍自己的额头。非常感谢。这是不对的。谢谢你,勒克斯。我把那部分从我的答案中删除了
import Ember from 'ember';
export default Ember.Route.extend({
store: Ember.inject.service(),
model(){
const poll = this.modelFor('polls.poll');
return this.get('store').createVote(poll);
},
actions: {
toggleOption(vote,option){
vote.toggleOption(option);
}
}
});