我的要求是使用来自另一个component.Need的组件操作来了解是否有可能在这种情况下使用数据压缩。
说,
我试图从这里调用第一个组件,如下所示:engine/addon/templates/application.hbs
engine/addon/templates/application.hbs
{{#if invokeFirstCompo}}
<FirstComponent action={{'actionFromSecondCompo'}}/>
{{/if}}从这个我想要调用的FirstComponent中,第二个组件函数在
engine/addon/components/SecondComponent.js
actionFromSecondCompo(){
console.log("Print Invoked secondcomponent");
}
Note: Both components are in same engine parent
i've tried to use **extend** the firstComponent in secomdCompo js like below.
>>engine/addon/components/SecondComponent.js从“engine/components/ FirstComponent”导入FirstComponent;导出默认FirstComponent.extend({
But issue here is, its invoking willDestroyElement() function from FirstComponent.Hence i don't need the changes handled inside this destroy function.发布于 2022-11-16 16:22:21
相关文档在这里:https://guides.emberjs.com/release/components/component-arguments-and-html-attributes/
但是,传递行为的方法是通过直接引用。
例如:
// SecondComponent
export default class extends Component {
someAction = () => {}
}{{! second component's template }}
<SomeOtherComponent @foo={{this.someAction}} />请注意,参数以@为前缀,类上的函数通过this.引用。
https://stackoverflow.com/questions/74441865
复制相似问题