gpt4 book ai didi

javascript - 等待后导出 ES6 模块

转载 作者:行者123 更新时间:2023-11-29 20:54:05 25 4
gpt4 key购买 nike

<分区>

我有一个模块需要导出,但我想在所有异步操作完成后导出它。本质上,我需要导出的模块在导出时“异步就绪”

class Store {
async dummy() {
await somethingElse()
}
}

const store = new Store();

// at this point, before exporting it, I want to
await store.dummy()

// but since I am not in a function, I cannot await it
export { store }

有什么想法吗?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com