0
import moment from '@salesforce/resourceUrl/XXX';
import { loadScript } from 'lightning/platformResourceLoader';

    export default class ProjectActivity extends LightningElement {
    connectedCallback(){
    Promise.all([
        loadScript(this, moment + '/js/moment.js')
        ]);
        this.loadActivities();
    }
    loadActivities(){
        let eventStartDate = moment(new Date()).format('YYYY-MM-DD');
    }
}
4

1 回答 1

0

您的问题是您loadActivities没有等待实际加载的时刻。

你需要做的是:

connectedCallback(){
    Promise.all([
          loadScript(this, moment + '/js/moment.js')
        ]).then(() => {
          this.loadActivities();
      });
    }
于 2020-05-29T05:06:39.373 回答