Tabs的具体使用方法,我这个报错The variable with @Link in component with @Preview may cause error in

这个说是组件问题,但是根本没法理解啊!

我报错的情况是:

[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/pages/Main.ets:25:3
[Compile Result]  The variable with @Link in component with @Preview may cause error in component preview mode
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/view/HomeView.ets:10:3
[Compile Result]  The variable with @Link in component with @Preview may cause error in component preview mode
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/view/HomeView.ets:11:3
[Compile Result]  The variable with @Link in component with @Preview may cause error in component preview mode
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/view/HomeView.ets:12:3
[Compile Result]  The variable with @Link in component with @Preview may cause error in component preview mode
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/view/AboutView.ets:7:9
[Compile Result]  The @Link property 'userInfo' cannot be an optional parameter.
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/components/NavigationComponent.ets:6:3
[Compile Result]  The variable with @Consume in component with @Preview may cause error in component preview mode
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/components/TitleComponent.ets:10:3
[Compile Result]  The variable with @Link in component with @Preview may cause error in component preview mode
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/components/TitleComponent.ets:11:3
[Compile Result]  The variable with @Link in component with @Preview may cause error in component preview mode
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/components/TitleComponent.ets:12:9
[Compile Result]  The @Link property 'userInfo' cannot be an optional parameter.
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/components/TitleComponent.ets:12:3
[Compile Result]  The variable with @Link in component with @Preview may cause error in component preview mode
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/components/CommunityComponent.ets:6:34
[Compile Result]  The @Link property 'userInfo' cannot be an optional parameter.
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/components/CommunityComponent.ets:6:3
[Compile Result]  The variable with @Link in component with @Preview may cause error in component preview mode
[Compile Result] ArkTS:WARN File: D:/save/myclass/xulaoshi/temp/atomgit_jiarong/entry/src/main/ets/components/CommunityComponent.ets:7:3
[Compile Result]  The variable with @Link in component with @Preview may cause error in component preview mode
Preview check failed. View the check result.
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.

无法显示效果:

Tabs的具体使用方法,我这个报错The variable with @Link in component with @Preview may cause error in -鸿蒙开发者社区

harmony
Tabs
6天前
135浏览
1
收藏 0
回答 1
已解决
回答 1
按赞同
/
按时间
红目香薰

我给你一个示例,这么用就没什么问题了:

  build() {
    // 使用 Stack 布局构建页面内容
    Stack() {
      // 使用 AtomicServiceTabs 组件创建底部导航栏和标签页内容
      AtomicServiceTabs({
        tabContents: [
          () => {
            this.tabContent1() // 第一个标签页内容:入账页面
          },
          () => {
            this.tabContent2() // 第二个标签页内容:出账页面
          },
          () => {
            this.tabContent3() // 第三个标签页内容:统计页面
          },
          () => {
            this.tabContent4() // 第四个标签页内容:个人中心页面
          }
        ],
        tabBarOptionsArray: this.listBar, // 设置底部导航栏选项数组
        tabBarPosition: TabBarPosition.BOTTOM, // 设置底部导航栏位置为底部
        barBackgroundColor: $r('sys.color.ohos_id_color_bottom_tab_bg'), // 设置底部导航栏背景颜色
        onTabBarClick: this.onTabClick, // 设置标签点击回调函数
        onContentWillChange: this.onContentWillChangeCallBack, // 设置内容将要改变的回调函数
      })
    }
    .height('100%') // 设置 Stack 布局的高度为 100%
  }
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.

好用的话希望采纳。

分享
微博
QQ
微信
回复1
6天前


相关问题
RSA 加密具体使用方法
899浏览 • 1回复 待解决
HarmonyOS 关于AOP具体使用方法
1160浏览 • 1回复 待解决
touchEvent使用方法
7423浏览 • 1回复 待解决
HarmonyOS AsyncCallback使用方法
1843浏览 • 1回复 待解决
日志工具类使用方法
1124浏览 • 1回复 待解决
HarmonyOS vp含义及使用方法
616浏览 • 1回复 待解决
HarmonyOS .ets文件中不能使用方法重载
542浏览 • 1回复 待解决
HarmonyOS NODE_ALIGN_SELF使用方法描述有误
1076浏览 • 1回复 待解决
HarmonyOS @Link使用问题
527浏览 • 1回复 待解决