LWC_004_异步等待

发布时间 2023-04-19 10:41:47作者: BandariFang

const promise = new Promise((resolve, reject) => {
setTimeout(() => {
this[NavigationMixin.Navigate]({
type: 'standard__webPage',
attributes: {
url: this.url + 'Information__c/new'
}
}
// Replaces the current page in your browser history with the URL
);

resolve('success!');
}, 0);
});

promise.then((result) => {


this[NavigationMixin.Navigate]({
type: 'standard__recordPage',
attributes: {
recordId: this.currentId,
objectApiName: 'Information__c',
actionName: 'view'
},

}, true
);


})


async connectedCallback() {
await Promise.resolve();
let apexResults = await Promise.all([ method1(params), method2(params) ])
// Do something with results
}