alibaba / alibaba/lowcode-engine

关于页面生命周期中异步函数的疑问

Open
#1,906 1 comment 0 reactions 1 assignee Assigned to @qingniaotonghua View on GitHub
enhancement module/codeout
Dominant language
TypeScript
Stars
15.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

## 现象
组件生命周期函数componentDidMount 声明是异步函数,出码就报错了。
![image](https://user-images.githubusercontent.com/27946984/232723298-59e38f28-d67b-491b-a3de-b98a34f58824.png)
![image](https://user-images.githubusercontent.com/27946984/232723363-9b8c9b60-5a0d-4b67-9adb-4155283cbf72.png)
我看是出码的时候把componentDidMount 函数名写死了,出码结果函数内容中有await但是方法名前面没有async。
这是故意这么设计的不让在生命周期函数中用await还是bug?
![image](https://user-images.githubusercontent.com/27946984/232723746-964dbf7e-fdc6-476d-94d0-17d36754e304.png)
然后无意中看到了源码面板介绍,有点懵了
![image](https://user-images.githubusercontent.com/27946984/232727490-3fa24801-e56d-403f-bbd2-8ad56a097859.png)
我没有在读取schema中的`originCode`之后自己手动通过babel编译。发现好像也没什么问题。

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.