Forked from dancinllama/gist:99ebc1c9afeb5d1243920552f0d7ed08
Created
May 16, 2019 01:30
-
-
Save jsmithdev/8171f4b3df8aa4601a463f94bcbb687d to your computer and use it in GitHub Desktop.
Loading moment.js in a LWC
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 } from 'lwc'; | |
import moment from '@salesforce/resourceUrl/moment'; | |
import { loadScript } from 'lightning/platformResourceLoader'; | |
export default class MomentStuffs extends LightningElement { | |
renderedCallback(){ | |
Promise.all([ | |
loadScript(this, moment + '/moment.js') | |
]).then(() => { | |
//Hey this works! | |
//moment() prints out stuff here in the render callback! | |
debugger; | |
}) | |
.catch(error => { | |
debugger; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment