Created
December 19, 2018 03:51
-
-
Save dancinllama/99ebc1c9afeb5d1243920552f0d7ed08 to your computer and use it in GitHub Desktop.
Loading moment.js in a LWC
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 } 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
Hi, just did same code in my VS code and I am just trying to print all data of moment. Also, console log but nothing is getting printed.