我的html文件:
<template> <lightning-button variant="brand" label={label} title={label} onclick={navigateNext}></lightning-button> </template>
我的js文件是:
var object = "Account";
var action = "edit";
export default class Navtab extends NavigationMixin(LightningElement) {
@api tabName;
@api label = '';
@api object = '';
@api action = '';
@api record = '';
navigateNext() {// Opens the new Account record modal// to create an Account.this[NavigationMixin.Navigate]({type: 'standard__objectPage',attributes:
{objectApiName: object,
actionName: action,
}});}}
我的xml文件是:
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="testingnew">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning\\\_\\\_AppPage</target>
<target>lightning\\\_\\\_RecordPage</target>
<target>lightning\\\_\\\_HomePage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning\\\\\\\_\\\\\\\_RecordPage,lightning\\\\\\\_\\\\\\\_HomePage">
<property name="label" type="String" default="Button" label="Enter the button label"/>
<property name="object" type="String" default="" label="Enter the object label"/>
<property name="action" type="String" default="" label="Enter the action label"/>
<property name="record" type="String" default="" label="Enter the button label"/>
<property name="url" type="String" default="" label="Enter the url label"/>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
所以基本上我想要的是每当我更改api对象属性时,我也希望它也更改js文件中的变量对象。在我的js文件中,有由objectapiname和actionname命名的属性,它们等于变量object和action,因此基本上在我更改api属性对象时,我也希望变量对象也被更改。我可以更改salesforce中的api属性,但不会更改变量对象和操作。