2017-12-18 186 views
0

我试图在导航栏右上角保持可触摸不透明度,对于onPress的可触摸不透明度。我想把用户带到主页。undefined不是一个对象(评估this.props.navigation)

constructor(props) { 
    super(props); 
    this.state = { 
     stAccntList: [], 
     stUserAccountNo: '', 
     stCustNo: '', 
     resp: '', 
    }; 


} 
static navigationOptions = { 
    // title: 'myacc', 
    title: 'My Accounts', 
    headerRight: <TouchableHighlight onPress={() => { 
     this.props.navigation.navigate('home'); 
    }}> 
     <Image style={{ marginRight: 20 }} source={require('../../../resources/toolbar/home_inactive.png')} /> 
    </TouchableHighlight>, 
    headerTintColor: 'white', 
    headerStyle: { 
     backgroundColor: colors.themeColor, 
     // top: 30 
    } 
} 

这是抛出红色屏幕上面的错误。请让我知道我要去哪里错了。

+0

你能指望什么'this'指在'this.props.navigation.navigate( '家');'? –

回答

0

试试这个是工作:)

  static navigationOptions = ({navigation}) => ({ 
       title: 'My Accounts', 
       headerRight: <TouchableHighlight onPress={() => { 
        navigation.navigate('home'); 
       }}> 
       <Image style={{ marginRight: 20, height: 30, width: 30 }} 
source={{ uri:https://media.freepik.com/accounts/img/badges/downloads_gold.png' 
    }} /> 
       </TouchableHighlight>, 
       headerTintColor: 'white', 
       headerStyle: { 
        backgroundColor: colors.themeColor, 
        // top: 30 
       } 
      }) 
+0

一些。语法错误 –

+0

你可以写错误@KartiikeyaBaleneni –

+0

哥们。添加代码后出现语法错误。编辑器中出现一些红色标记。 –

相关问题