Custom Label use in LWC #inSalesforce

Custom Label use in LWC:


<template>
    <lightning-card  title='Sample' variant="narrow">
        <p>{label.Sample}</p>
    </lightning-card>
</template>


import { LightningElement } from 'lwc';
import Sample from '@salesforce/label/c.Sample';
export default class CustomLabelExampleLWC extends LightningElement {
    label = {
        Sample
    };
}


<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>48.0</apiVersion>
    <isExposed>true</isExposed>
    <targets> 
        <target>lightning__AppPage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__HomePage</target>
    </targets>
</LightningComponentBundle>



Reference: https://thesalesforcetutorial.blogspot.com/2023/02/custom-labels-insalesforce.html

Comments