ArkUI Preview错误:A page configured in ‘main_pages.json‘ must have one and only one ‘@Entry‘ decorator
出现错误的原因是在ArkUI里面规定,在单个页面中【注意,不是组件】,需要使用@Entry装饰器,指定一个自定义组件作为页面入口,所以,在自己的页面中添加@Entry就可以正常预览了。仔细一想,确实合理,被@Entry修饰的表示一个页面的入口,所以不需要export,export的应该是组件。这时,出现警告, 大致意思是,不建议使用export导出一个被@Entry装饰的struct。点击PreV
文章共327字 · 阅读需要大约2分钟
一键AI生成摘要,助你高效阅读
问答
·
错误提示
[Compile Result] ArkTS:ERROR File: C:\Users\Young\DevEcoStudioProjects\ToDo\entry\src\main\ets\pages\createMission.ets
[Compile Result] A page configured in 'main_pages.json' must have one and only one '@Entry' decorator.
[Compile Result] Compile error occurred. Fix it based on the above message.
出现错误的原因是在ArkUI里面规定,在单个页面中【注意,不是组件】,需要使用@Entry装饰器,指定一个自定义组件作为页面入口,所以,在自己的页面中添加@Entry
点击PreView的刷新按钮,就可以正常预览了
警告
[Compile Result] ArkTS:WARN File: C:\Users\Young\DevEcoStudioProjects\ToDo\entry\src\main\ets\pages\createMission.ets:2:1
[Compile Result] It's not a recommended way to export struct with @Entry decorator, which may cause ACE Engine error in component preview mode.
这时,出现警告, 大致意思是,不建议使用export导出一个被@Entry装饰的struct
所以,删除export关键字即可。
仔细一想,确实合理,被@Entry修饰的表示一个页面的入口,所以不需要export,export的应该是组件
更多推荐
已为社区贡献1条内容
所有评论(0)