子LWC到Aura Component的起火事件

问题描述

我有一个父级LWC组件和一个子级LWC组件。 我将来自父级的记录ID传递给子级组件

<template if:true={secondLeadIdDispatch}>
    <template if:true={secondLeadId}>
        <span>
            <c-lead-status-update-sub-tab-param lead-record-id={secondLeadId}></c-lead-status-update-sub-tab-param>
        </span>
    </template>
</template>

然后从子组件中,我在connectedCallback构造函数中调度一个事件,该事件的记录为Id:

connectedCallback() {
    if (this.leadRecordId) {
        let leadRecordIdParam = this.leadRecordId;
        const secondLeadIdEvent = new CustomEvent('leadrecordidevent',{detail: leadRecordIdParam},);
        this.dispatchEvent(secondLeadIdEvent);
    }
}

我还有一个Aura组件,该组件封装了调度事件的子组件。 我使用HTML事件来处理来自controller.js方法中的子LWC组件的事件:c.handleOpenSubTab

<aura:component description="leadStatusUpdateWrapper" implements="flexipage:availableForAllPageTypes" access="global" >
<lightning:workspaceAPI aura:id="workspace" />
<div>
    <c:leadStatusUpdateSubTabParam onleadrecordidevent="{!c.handleOpenSubTab}"/>
</div>
</aura:component>

用于处理事件的controller.js方法如下:

handleOpenSubTab: function(component,event,helper) {
    console.log('Inside handle subtab method');
    var leadRecordId = event.getParam('leadRecordIdParam');
    console.log('Aura second lead id:',leadRecordId);
}

问题似乎是Aura组件未从LWC组件获取调度事件。在调度事件之后,我还添加了console.log以确保它已执行。 contoller.js上的方法未执行。 我遵循了Lightning Web Component Library中的示例。我在做什么错了?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...