当前位置: 首页 > news >正文

ArkTS问题:怎么提升代码的优先级呢?

如题,现在我这边有个问题。
代码片段:
...
this.firstFunction();
this.secondFunction();
this.thirdFunction();
...

现在,出现的情况就是,firstFunction()必须得执行完成,secondFunction()和thirdFunction()才能成功完成,否则会出现错误。但是问题就是,ArkTS里面好像并没有优先级?
怎么让secondFunction()和thirdFunction()在firstFunction()完成之后才执行呢?

现况:
解决代码片段:
...
this.firstFunction();
setTimeout(() => {
this.secondFunction();
this.thirdFunction();
}, 100)

这虽然是不错的想法,但是治标不治本,属于是邪修了。有没有更好一点的方法呢?

感谢好心人的回答