首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Salesforce -使用消息服务问题发布Aura组件

Salesforce -使用消息服务问题发布Aura组件
EN

Stack Overflow用户
提问于 2020-10-07 19:15:51
回答 1查看 69关注 0票数 0

我正在尝试将Aura中的数据发布到LWC。我得到了错误,以纠正我遗漏的东西。我检查了多个例子作为语法智慧,仍然不起作用。因此发帖看看是否有人能帮上忙。

Aura组件html:

代码语言:javascript
复制
<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:

代码语言:javascript
复制
({
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文件

代码语言:javascript
复制
<?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

有谁能帮助我,我错过了什么?

EN

回答 1

Stack Overflow用户

发布于 2020-11-10 00:13:03

该消息似乎表明您的消息通道未被识别。"masterLabel“不是消息通道的接口名称,而是文件名。例如,如果你在一个文件AlertMessageChannel.messagecannnel-meta.xml中定义了你的xml,那么你可以用"AlertMessageChannel__c“引用你的频道。如果你的文件名不同,比如"TestChannel.messageChannel-meta.xml“,那么你必须使用"TestChannel__c”。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64242896

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档