Ember 对包装器组件触发操作
Ember trigger action on wrapper component
我有一个包装器组件,它有一个需要从内部触发的动作,但我无法摆脱它:
{{#wrapper-component as |wrapper|}}
<button {{action 'wrapper.myAction'}}
{{/wrapper-component}}
以上是"componentA"的模板;当我单击该按钮时,我收到一条错误消息,指出 componentA 没有 "wrapper.myAction" 的操作处理程序;我不明白为什么它首先在 componentA 而不是 wrapper-component 上寻找动作。
当然 "myAction" 是在 "wrapper-component" 上的 "actions" 中定义的;
包装器组件具有此模板:
{{yield (hash myAction=(action 'myAction'))}}
替换为:
<button {{action 'wrapper.myAction'}}
有了这个:
<button onclick={{action wrapper.myAction}}
请确保您了解 ember 操作和关闭操作之间的区别。
我有一个包装器组件,它有一个需要从内部触发的动作,但我无法摆脱它:
{{#wrapper-component as |wrapper|}}
<button {{action 'wrapper.myAction'}}
{{/wrapper-component}}
以上是"componentA"的模板;当我单击该按钮时,我收到一条错误消息,指出 componentA 没有 "wrapper.myAction" 的操作处理程序;我不明白为什么它首先在 componentA 而不是 wrapper-component 上寻找动作。 当然 "myAction" 是在 "wrapper-component" 上的 "actions" 中定义的; 包装器组件具有此模板:
{{yield (hash myAction=(action 'myAction'))}}
替换为:
<button {{action 'wrapper.myAction'}}
有了这个:
<button onclick={{action wrapper.myAction}}
请确保您了解 ember 操作和关闭操作之间的区别。