I created component as Lightning Web Component. In VSCode it's ok. When in Lightning App Builder I added this component, there is a bug: "Error during LWC component connect phase: [Cannot read property 'fields' of undefined]"
product.html:
<template>
<div class="container">
<a onclick={productClick}>
<div class="product">{name}</div>
</a>
<a onclick={addToCart}>
<div class="product">Add to cart</div>
</a>
</div>
</template>
product.js:
import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
const FIELDS = [
'Account.Name',
'Account.Phone'
];
export default class Product extends LightningElement {
@api item; // public property
item = recordId;
@wire(getRecord, { recordId: '$recordId', fields: FIELDS })
account;
get name() {
console.log('Returned value: ' + this.account.data.fields.Name.value);
return this.account.data.fields.Name.value;
}
productClick() {
}
addToCart() {
}
}
I use API v.51. It is programmed according to this manual.