首页 > 建站教程 > APP开发,混合APP >  It's not a recommended way to export struct with @Entry decorator, which may cause ACE Engine error in component preview mode.正文

It's not a recommended way to export struct with @Entry decorator, which may cause ACE Engine error in component preview mode.

开发原生鸿蒙的时候,出现了下面的提示:

[Compile Result] ArkTS:WARN File: G:/work/testApp/entry/src/main/ets/pages/Profile.ets:4: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.

代码如下:

@Entry
@Component
export default struct User {
  topRectHeight: string = AppStorage.get<number>('topRectHeight') + 'px';
  aboutToAppear(): void {
    font.registerFont({
      familyName: 'iconfont',
      familySrc: '/fonts/iconfont.ttf'
    })
  }
//....

仔细看,这是页面,竟然在struct前面写了导出,删掉“export default”即可。不过不删除也不影响,就是有这个warning提示。