Created
December 2, 2019 10:06
-
-
Save pradeep-dani/aff5c324c18f62ae773e661cd868e597 to your computer and use it in GitHub Desktop.
LWC File structure with many modulated JS files
This file contains 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
export function isFunction(value) { | |
return 'Test'+ value; | |
} |
This file contains 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> | |
<lightning-card title="Details" icon-name="custom:custom14"> | |
<div class="slds-m-around_medium"> | |
<p>Hello, {greeting}! {result}!</p> | |
<lightning-input label="Name" value={greeting} onchange={changeHandler}></lightning-input> | |
</div> | |
</lightning-card> | |
</template> |
This file contains 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'; | |
import { isFunction } from './helper'; | |
export default class HelloWorld extends LightningElement { | |
@track greeting = 'world'; | |
@track result = 'init'; | |
changeHandler(event) { | |
this.greeting = event.target.value; | |
// Call the imported library function | |
this.result = isFunction(' ' + event.target.value + ' ;'); | |
} | |
} |
This file contains 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" fqn="helloWorld"> | |
<apiVersion>45.0</apiVersion> | |
<isExposed>true</isExposed> | |
<targets> | |
<target>lightning__AppPage</target> | |
<target>lightning__RecordPage</target> | |
<target>lightning__HomePage</target> | |
</targets> | |
</LightningComponentBundle> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment