[英]Lightning Web Component Not Working in Contact Detail Page
I have the following lightning web component. 我有以下闪电网络组件。
MyPage.html myPage.html下
<template>
<lightning-record-form
object-api-name={contactObject}
fields={myFields}
onsuccess={handleContactCreated}>
</lightning-record-form>
</template>
MyPage.js MyPage.js
import { LightningElement } from 'lwc';
import CONTACT_OBJECT from '@salesforce/schema/Contact';
import NAME_FIELD from '@salesforce/schema/Contact.Name';
export default class ContactCreator extends LightningElement {
contactObject = CONTACT_OBJECT;
myFields = [NAME_FIELD];
handleContactCreated(){
// Run code when account is created.
}
} }
This works if I drop this lightning component in Account record detail page. 如果我在帐户记录详细信息页面中删除此闪电组件,则此方法有效。 But it does not work in Contact record detail page.
但它在“联系记录详细信息”页面中不起作用。
No matter how many times I save it, it disappears. 无论我保存多少次,它都会消失。 when I come and check it again in the contact record detail page, it's not there.
当我再次在联系记录详细信息页面中对其进行检查时,它不存在。
Can someone help ? 有人可以帮忙吗?
You must have a reference to the Contact page in your web components meta.xml file. 您必须在Web组件meta.xml文件中具有对“联系人”页面的引用。 I'm assuming yours looks like this:
我假设你的看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"
fqn="nameOfComponent">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__RecordPage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordPage">
<objects>
<object>Account</object>
</objects>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
when you need to add Contact as an object inside the objects tags. 当您需要在对象标签内添加联系人作为对象时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.