Skip to content

Instantly share code, notes, and snippets.

@pradeep-dani
Created December 2, 2019 10:06
Show Gist options
  • Save pradeep-dani/aff5c324c18f62ae773e661cd868e597 to your computer and use it in GitHub Desktop.
Save pradeep-dani/aff5c324c18f62ae773e661cd868e597 to your computer and use it in GitHub Desktop.
LWC File structure with many modulated JS files
export function isFunction(value) {
return 'Test'+ value;
}
<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>
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 + ' ;');
}
}
<?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