今天我有一个令人震惊的发现:在 View 上引用的操作是由它们的路由处理的,而不是由引用它的 View 处理。前任:
<a href="#" {{action edit}}>Edit this</a>
edit
Action 必须在 Route 中定义,而不是在 View 中。在 View 负责处理此类事件之前我不使用路由器时,我对此感到非常高兴。任何人都可以请:
最佳答案
将目标设置为 View
<a href="#" {{action edit target="view"}}>Edit this</a>
如果您的操作在 Controller 中,则使用
<a href="#" {{action edit}}>Edit this</a>
默认目标是指 View 的 Controller
我建议你通过这个引用:Ember Action Helper
我想根据上述引用提及一些关键点
关于view - EmberJS : How to handle actions from the View not the Route/Controller,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13178441/