如何使用在闪电中的URL中打开的onclick添加按钮

时间:2019-05-28 16:20:56

标签: javascript salesforce-lightning

所以有两个文件,我想同时使用它们来使用onclick来添加单击按钮时打开url的功能。

HTML文件

    <div class="slds-m-top_medium slds-m-bottom_x-large">
        <h2 class="slds-text-heading_medium slds-m-bottom_medium">
            Click the example buttons to activate the <code>onclick</code> handler and view the label of the clicked button.
        </h2>

        <!-- Neutral variant (default) -->
        <lightning-button label="Neutral" title="Neutral action" onclick={handleClick} class="slds-m-left_x-small"></lightning-button>

    </div>

    <div class="slds-m-vertical_medium">
        <p>The label of the button that was clicked is: <span class="slds-text-heading_small">{clickedButtonLabel}</span></p>
    </div>
</template>

JS文件


export default class ButtonBasic extends LightningElement {
    @track clickedButtonLabel;

    handleClick(event) {
        this.clickedButtonLabel = event.target.label;
    }
}

0 个答案:

没有答案