<template>
<template if:true={contact}>
<lightning-layout vertical-align="center">
<lightning-layout-item padding="around-small">
<p>{contact.Name}</p>
<p>{contact.Title}</p>
<p>
<lightning-formatted-phone
value={contact.Phone}
></lightning-formatted-phone>
</p>
</lightning-layout-item>
</lightning-layout>
</template>
<template if:false={contact}
><p>No contact data available.</p></template
>
</template>
js code:
import { LightningElement, api } from 'lwc';
export default class ContactTile extends LightningElement {
@api contact;
}
xml:
Where i am doing a mistake.<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordPage">
<objects>
<object>contact</object>
</objects>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
As suggest earlier you can use wire to call apex or can use LDS too.
You can use lightning-record-form, lightning-record-edit-form, or lightning-record-view-form components.You can check more details here.https://newstechnologystuff.com/2018/12/16/lightning-web-component-the-new-development-style/https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.data_ui_apiThanksTusharhttps://newstechnologystuff.com/<template>
<lightning-card title="Record Edit Form Contact" icon-name="standard:contact">
<div class="slds-m-around_medium">
<lightning-record-edit-form
object-api-name="Contact"
record-id="recordId">
<lightning-messages></lightning-messages>
<lightning-input-field field-name="Name"></lightning-input-field>
<lightning-input-field field-name="Title"></lightning-input-field>
<lightning-input-field field-name="Phone"></lightning-input-field>
<lightning-input-field field-name="Email"></lightning-input-field>
<div class="slds-m-top_medium">
<lightning-button variant="brand" type="submit" name="save" label="Save"></lightning-button>
</div>
</lightning-record-edit-form>
</div>
</lightning-card>
</template>