错误提示

在这里插入图片描述

[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的应该是组件

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐