June 20, 2020

How to get query parameters or URL parameters using LWC in Salefsorce?

Sample Code:

import { LightningElement, wire } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';

export default class Sample extends LightningElement {

    @wire(CurrentPageReference)
    currentPageReference;

    connectedCallback() {
       
        console.log( 'Param ' + this.currentPageReference.state.recId );
   
    }

}

Output:


No comments:

Post a Comment