我正在尝试将Aura中的数据发布到LWC。我得到了错误,以纠正我遗漏的东西。我检查了多个例子作为语法智慧,仍然不起作用。因此发帖看看是否有人能帮上忙。
Aura组件html:
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<a href="javascript:void(0);" onclick="{!c.publishMC}">More Information</a>
<lightning:messageChannel type="AlertMessageChannel__c" aura:id="AlertMessageChannel"></lightning:messageChannel>
</aura:component>Aura控制器JS:
({
publishMC : function(component, event, helper) {
var messageInfo = [
{ normalTxt: '', boldTxt: '', boldLeftTxt: 'This opportunity is Stale',
normalRightTxt: 'the stale reason code is EOD PAST DUE.'},
{ normalTxt: '', boldTxt: '', boldLeftTxt: 'This account has 1 or more Frame
Agreements', normalRightTxt: 'There is a Frame Agreement associated to the account,
if applicable, please link to this opportunity using the Contract ID field.'},
];
component.find("AlertMessageChannel").publish(messageInfo);
}
})我还添加了消息服务xml文件
<?xml version="1.0" encoding="UTF-8"?>
<LightningMessageChannel xmlns="http://soap.sforce.com/2006/04/metadata">
<description>This is a alert message channel communicator</description>
<isExposed>true</isExposed>
<lightningMessageFields>
<description>Header information passed into alert modal window</description>
<fieldName>alertHeaderInfo</fieldName>
</lightningMessageFields>
<lightningMessageFields>
<description>Body information passed into alert modal window</description>
<fieldName>alertBodyInfo</fieldName>
</lightningMessageFields>
<lightningMessageFields>
<description>Show/Hide information passed into alert modal window</description>
<fieldName>alertVisibleInfo</fieldName>
</lightningMessageFields>
<masterLabel>AlertMessageChannel</masterLabel>但是当尝试加载时,得到的错误如下:
操作失败: Lightning : MessageChannel $MessageChannel$init Lightning Message Service -无法识别的控制器引用: AlertMessageChannel__c
有谁能帮助我,我错过了什么?
发布于 2020-11-10 00:13:03
该消息似乎表明您的消息通道未被识别。"masterLabel“不是消息通道的接口名称,而是文件名。例如,如果你在一个文件AlertMessageChannel.messagecannnel-meta.xml中定义了你的xml,那么你可以用"AlertMessageChannel__c“引用你的频道。如果你的文件名不同,比如"TestChannel.messageChannel-meta.xml“,那么你必须使用"TestChannel__c”。
https://stackoverflow.com/questions/64242896
复制相似问题