miniprogram-compat icon indicating copy to clipboard operation
miniprogram-compat copied to clipboard

关于 Generator 函数的疑问

Open chenjiahan opened this issue 4 years ago • 1 comments

按照本仓库中的数据,从基础库 2.11 开始就可以使用 Generator 函数。

image

在我们的项目中,我们使用 @babel/preset-env@babel/plugin-transform-runtime 进行编译,将 target 设置为 iOS >= 10,同时关闭了开发者工具自带的 ES6 转 ES5增强编译,理论上是可以使用 Generator 的。

但我们在 iOS 10 真机验证过程中发现,Generator 会产生以下异常:

image

在开放社区中也有类似的反馈:

  • https://developers.weixin.qq.com/community/develop/doc/00080c83528300fe011a6ed2051400?highLine=generator
  • https://developers.weixin.qq.com/community/develop/doc/0000403a7345881bbd57bbfa856000?highLine=Generator

请问以上异常是否与小程序的 JS 执行环境有关呢?

chenjiahan avatar Oct 08 '21 11:10 chenjiahan

基础库 2.17.1 之前的 generator 函数存在问题,建议尽量避免使用

Tidyzq avatar Dec 03 '21 12:12 Tidyzq