相关疑难解决方法(0)

TypeScript中的异步构造函数?

我在构造函数中有一些我想要的设置,但似乎是不允许的

没有异步const

这意味着我不能使用:

等待

我该怎么做呢?

目前我有类似的东西,但这不保证按我想要的顺序运行?

async function run() {
  let topic;
  debug("new TopicsModel");
  try {
    topic = new TopicsModel();
  } catch (err) {
    debug("err", err);
  }

  await topic.setup();
Run Code Online (Sandbox Code Playgroud)

constructor async-await typescript

58
推荐指数
7
解决办法
4万
查看次数

标签 统计

async-await ×1

constructor ×1

typescript ×1