我试图在导航栏的右上角保持可触摸的不透明度,对于可触摸不透明度的onPress。我想将用户带到主页。
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
}
}
它正在抛出红色屏幕,上面有错误。请让我知道我哪里出错了。
试试这是工作:)
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
}
})