仓颉开发HarmonyOS,报错error: undeclared identifier 'ViewStackProcessor'

仓颉开发HarmonyOS,报这个错:

error: undeclared identifier 'ViewStackProcessor'
   | 
   | /* 42.24 */        ViewStackProcessor.StartGetAccessRecordingFor(ViewStackProcessor.AllocateNewElmetIdForNextComponent())
   |                    ^^^^^^^^^^^^^^^^^^ 
   | 
note: the error occurs after the macro is expanded
   ==> D:\workspace\gitee\develop-native-harmonyos-ai-assistant-with-cangjie-video\samples\ch5\CangjieAiAssistant\entry\src\main\cangjie\src\page\intelligent_chat_page.cj:42:1:
    | 
42  |   @Entry
    |  _^
43  | | @Component
    | | ...
125 | | }
    | |_^
    |
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.

已知,是在代码里面用了if/else引起的,有谁知道问题在哪?

func build() {
        if (isSelf) {
            Row() {
                Row() {
                    Text(content)
                }.padding(10).backgroundColor(0xffffff).borderRadius(10).constraintSize(maxWidth: 90.percent).margin(
                    right: 10)
            }.justifyContent(FlexAlign.End).width(100.percent).padding(left: 10).margin(top: 10, bottom: 10)
        } else {
            Row() {
                Row() {
                    Text(content)
                }.padding(10).backgroundColor(0xffffff).constraintSize(maxWidth: 90.percent).borderRadius(10).margin(
                    left: 10)
            }.width(100.percent).padding(right: 10).margin(top: 10, bottom: 10, right: 10)
        }
    }
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
HarmonyOS
仓颉
鸿蒙
2025-03-26 11:26:28
1045浏览
1
收藏 0
回答 1
已解决
回答 1
按赞同
/
按时间
funnyLUO2025

导入这个包即可

 

internal import ohos.state_manage.ViewStackProcessor

分享
微博
QQ
微信
回复
2025-03-27 14:29:32


相关问题
HarmonyOS 可以用仓颉开发HarmonyOS
745浏览 • 1回复 待解决
冷启动报错Error message
2741浏览 • 1回复 待解决
报错Error while Deploying HAP。
13333浏览 • 2回复 待解决
可以用仓颉开发鸿蒙应用吗?
148浏览 • 1回复 已解决
HarmonyOS 闪退报错 Error code:2100001
672浏览 • 1回复 待解决
HarmonyOS identifier.getOAID 获取失败
1097浏览 • 1回复 待解决
仓颉编程语言也能开发手机APP吗?
215浏览 • 1回复 已解决