菜鸟教程小白 发表于 2022-12-11 17:07:16

ios - react-native NavigatorIOS rightButton 无法点击


                                            <p><p>react-native NavigatorIOS rightButton 无法点击。</p>

<pre><code>onRightButtonPress: function(){

   this.refs.nav.push({
       title: &#39;From Right&#39;,
       component: DetailViewController,
   })
},
</code></pre>

<p>当我点击 <code>rightButton</code></p> 时没有任何反应

<pre><code> render() {
    return (
      &lt;NavigatorIOS ref=&#34;nav&#34;

      initialRoute={{
          component: HomeScene,      
          title: &#39;NavigatorIOS Demo..&#39;,
          rightButtonTitle: &#39;MORE!&#39;,
          onRightButtonPress: this.onRightButtonPress,

          leftButtonTitle:&#39;leftItem&#39;,
      }}&gt;
      &lt;/NavigatorIOS&gt;
    );
},
});
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您需要将方法绑定(bind)到“this”。
或者,使用 => 符号来定义方法。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - react-native NavigatorIOS rightButton 无法点击,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/38609443/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/38609443/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - react-native NavigatorIOS rightButton 无法点击