0
点赞
收藏
分享

微信扫一扫

A page must have one and only one ‘@Entry‘ decorator with a struct.【BUG已解决】

项目场景:

在学习基于OpenHarmony/HarmonyOS操作系统的ArkUI框架的过程中,使用DevEco Studio 3.0.0.993打开一个小的Demo的过程中。 打开Previewer的时候爆出如下错误:

mpile Result] A page configured in 'config.json' must have one and only one '@Entry' decorator. [Compile Result] Compile error occurred. Fix it based on the above message.

报错页面1: 在这里插入图片描述 报错页面2: 在这里插入图片描述

问题描述

出现如下报错: mpile Result] A page configured in 'config.json' must have one and only one '@Entry' decorator. Compile Result] Compile error occurred. Fix it based on the above message.

我的项目目录结构: 在这里插入图片描述

原因分析:

翻译结果: 在“config”中配置的页面。json'必须且只能有一个'@Entry'装饰器。 在config.json中“pages” : [ 配置了该文件 ],导致编译器认为此文件是页面,必须加修饰器@Entry。 发生编译错误。根据上面的消息修复它。

解决方案:

检查index.ets的文件开头是否引用了装饰器:@Entry。 在这里插入图片描述

import Myinput from "../common/componets/myinput"
@Entry
@Component
struct Index {
  @State message: string = 'OpenHarmony'
  @State username: string='1上进小菜猪23'
  @State password: string='3241'
  // @ts-ignore
  private username_reg= /^[0-9a-zA-Z]{5,8}/;

改正后检测,是否成功: 在这里插入图片描述 该BUG【A page must have one and only one '@Entry' decorator with a struct】成功解决。

举报

相关推荐

0 条评论