简体   繁体   English

未反映合并选项更改

[英]mergeOptions changes not reflected

I'm trying to get a badge to display on one of the navigation tabs.我正在尝试在其中一个导航选项卡上显示徽章。

 onClickSetBadge() { console.log('Button pressed!') Navigation.mergeOptions(this.props.componentId, { bottomTab: { badge: `TeSt` } }); }

I'm calling it inside the view I'm rendering.我在我正在渲染的视图中调用它。

 <ButtonView text='SUP' onPress={() => {this.onClickSetBadge()}} />

The log statement shows up in my console, however, the badge is not shown.日志语句显示在我的控制台中,但是没有显示徽章。

According to the official document: https://wix.github.io/react-native-navigation/#/docs/layout-types?id=updating-options-for-a-specific-tab , that is how it works:根据官方文档: https : //wix.github.io/react-native-navigation/#/docs/layout-types?id=updating-options-for-a-specific-tab ,它是这样工作的:

1) Define an id for the specific tab: 1) 为特定选项卡定义一个 id:

    stack: {
      id: 'CartTab',
      children: [{
        component: {
          name: 'store-cart',
        }
      }],
      options: {
        bottomTab: {
          text: 'Cart',
          icon: require('../asset/image/menu/cart.png'),
        }
      }
    }

2) Use the tab id to update when needed: 2) 需要时使用标签 ID 进行更新:

  Navigation.mergeOptions('CartTab', {
    bottomTab: {
      badge: cart.length > 0 ? cart.length.toString() : ''
    }
  });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM