Created
May 5, 2020 01:21
-
-
Save JitendraZaa/46a8860e99e2e96699e26a7fd89c4f98 to your computer and use it in GitHub Desktop.
Jitendra Zaa Blog on how to define reusable LWC component to share Javascript code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
... Some UI related code here | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement , track } from 'lwc'; | |
//Importing reusable LWC Component as Javascript utility | |
import {getUrlParameter } from 'c/JSUtility'; | |
export default class DemoWrapperLWC extends LightningElement { | |
//Some track variables define | |
//...... | |
//.. Some code | |
//Similar to init method in Aura | |
connectedCallback() { | |
//Note - We are NOT using "this" keyword to access method getUrlParameter | |
let param1 = getUrlParameter('param1'); | |
console.log('Found Parameter value for param1'+param1); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | |
<apiVersion>48.0</apiVersion> | |
<isExposed>true</isExposed> | |
<targets> | |
<target>lightning__AppPage</target> | |
<target>lightning__RecordPage</target> | |
<target>lightning__HomePage</target> | |
<target>lightningCommunity__Page</target> | |
<target>lightningCommunity__Default</target> | |
</targets> | |
</LightningComponentBundle> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment