【问题标题】:mergeOptions changes not reflectedmergeOptions 更改未反映
【发布时间】:2018-12-23 01:49:13
【问题描述】:

我正在尝试在其中一个导航选项卡上显示徽章。

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

我在我正在渲染的视图中调用它。

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

日志语句显示在我的控制台中,但是未显示标记。

【问题讨论】:

    标签: javascript react-native react-native-navigation wix-react-native-navigation


    【解决方案1】:

    根据官方文档:https://wix.github.io/react-native-navigation/#/docs/layout-types?id=updating-options-for-a-specific-tab,是这样的:

    1) 为特定选项卡定义一个 id:

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

    2) 在需要时使用标签 id 进行更新:

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

    【讨论】:

      猜你喜欢
      • 2014-07-12
      • 2015-03-06
      • 2015-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-27
      • 2023-02-10
      相关资源
      最近更新 更多