1 个回答

我们全局使用了Navigation模式,页面级Component都使用的NavDestination,想全局设置一下NavDestination的背景颜色,有什么办法吗?我试过了下面三种方式,都不生效。

1.Window.setWindowBackgroundColor

2.设置主题 https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/theme\_skinning-V5

3.设置入口Navigation背景

@Entry
@Component
struct Launch {
  @Builder
  routerMap(builderName: string, param: object) {
    DynamicsRouter.getBuilder(builderName).builder(param)
  };

  build() {
    Navigation(DynamicsRouter.navPathStack) {
      // 空页面 用于跳转
      NavDestination() {
        Column().backgroundColor(Color.Transparent)
      }.hideTitleBar(true).onReady(() => {
        DynamicsRouter.replace("splash/SplashScreenPage")
      })
    }.hideNavBar(true)
    .navDestination(this.routerMap)
    .width('100%')
    .height('100%')
    .backgroundColor(Color.Red)
  }
}

1、对于 NavDestination 组件属性设置目前需要单独对每个组件设置属性;

2、目前全局复用(模块级)样式,可以进行动态属性设置,attributeModifier属性:可以设置组件常规状态样式、按压样式等多个状态样式展示

具体支持组件以及方法可参考以下链接实现:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-attribute-modifier-V5

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进