0

我有以下闪电网络组件。

我的页面.html


 <template>
   <lightning-record-form
          object-api-name={contactObject}
          fields={myFields}
          onsuccess={handleContactCreated}>
  </lightning-record-form>
 </template>

我的页面.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.
}

}

如果我将这个闪电组件放在帐户记录详细信息页面中,这将起作用。但它在联系人记录详细信息页面中不起作用。

无论我保存多少次,它都会消失。当我再次在联系人记录详细信息页面中查看时,它不存在。

有人可以帮忙吗?

4

1 回答 1

1

您必须在 Web 组件 meta.xml 文件中引用联系人页面。我假设你的看起来像这样:

<?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>

当您需要将联系人添加为对象标签内的对象时。

于 2019-03-12T11:13:21.370 回答