Variables in LWC (as you know them in Java, Python, etc.) are called Properties in LWC.
itemName
maps to an HTML attribute called item-name
.Don’t start a property name with:
on
(for example, onClick
)aria
(for example, ariaDescribedby
)data
(for example, dataProperty
)And don’t use these reserved words for property names.
slot
part
is
There are 3 types of properties in LWC:
@track
decorator@api
decoratorIt is declared using only an identifier name and don’t need a datatype.
_variable
to indicate that is a private property.This is a simple example:
<template>
<lightning-card title="Greeting Message" icon-name="custom:custom14">
<div class="slds-var-m-around_medium">
<p>{greetingMessage}</p>
</div>
</lightning-card>
</template>