Skip to main content
Call lwc method from Aura component
Call lwc method from Aura component:
parentcomponent:
html:
<aura:component>
<!--parent content-->
<c:childcomponent aura:id="childCompId"></c:childcomponent >
<lightning:button label="justCallChild" variant="brand" onclick="{!c.callChildMethod}" ></lightning:button>
</aura:component>
js:
({
callChildMethod : function(component, event, helper) {
var getChild = component.find('childCompId');
getChild.childComponentMethod('test');
}
})
childcomponent:
html:
<template>
child content
</template>
js:
import { LightningElement,api } from 'lwc';
export default class childcomponent extends LightningElement {
@api
childComponentMethod(msg){
console.log('??????'+ msg);
}
}
App for testing:
<aura:application>
<c:parentcomponent></c:parentcomponent>
</aura:application>
Comments
Post a Comment