As mentioned in the previous responses, fieldset isn't supported in LWC yet.However, it can be accessed using an Apex Class. Below is one example of the apex class which can be used.
public without sharing class MyFieldSetApexClass {
public MyFieldSetApexClass() {
}
public static List<Schema.FieldSetMember> getFields() {
return SObjectType.Account.FieldSets.examplefieldset.getFields();
}
@AuraEnabled(cacheable=true)
public static Account getAccountList(id accid) {
String query = 'SELECT ';
for(Schema.FieldSetMember f : MyFieldSetApexClass.getFields()) {
query += f.getFieldPath() + ', ';
}
query += 'Id FROM Account WHERE ID=\''+accid+'\'';
System.debug(query);
return Database.query(query);
}
}
and the below is the example of the js file which utilises the MyFieldSetApexClass class
import { LightningElement, wire, track, api } from 'lwc';
import accFieldSet from '@salesforce/apex/MyFieldSetApexClass.getAccountList';
export default class MyFielSetComponent extends LightningElement {
@track accs;
@track error;
@api recordId;
@wire(accFieldSet, { accid: '$recordId' })
wiredContacts({ error, data }) {
if (data) {
this.accs = data;
this.error = undefined;
} else if (error) {
this.error = error;
this.accs = undefined;
}
}
}
Below is the example HTML code.
<template>
<lightning-card title="AccountFieldSet" icon-name="custom:custom63">
<div class="slds-m-around_medium">
<template if:true={accs}>
<div class="slds-box slds-box_x-small">
<p>Name: {accs.Name}</p>
<p>Industry: {accs.Industry}</p>
<p>Description: {accs.Description}</p>
</div>
</template>
<template if:true={error}>
<c-error-panel errors={error}></c-error-panel>
</template>
</div>
</lightning-card>
</template>
This is just an example to support the previous responses. Hope this helps. :)