HarmonyOS @Concurrent?

以下代码,在IDE中报错:

Only imported variables and local variables can be used in @Concurrent decorated functions. <ArkTSCheck\>

class BBB{
  name = ""
}
@Concurrent
function aaa(): number {
  new BBB().name
  return 1
}
阅读 523
1 个回答

在arkts中需要分为两个文件进行编写

参考以下示例

222.ets:

export class BBB{
  name = ""
}

111.ets:

import {BBB} from './222'
@Concurrent
function aaa(): number {
  new BBB().name
  return 1
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进