Как добавить кнопку с помощью onclick, которая открывается в URL в молнии - PullRequest
0 голосов
/ 28 мая 2019

Итак, есть два файла, и я хочу использовать их оба, чтобы использовать функцию 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;
    }
}
...