【发布时间】:2017-10-10 14:04:46
【问题描述】:
请帮助我从静态导航选项内部访问 Page1 类。 仅供参考,请不要建议使用 .this,因为它不起作用,并且必须在 navigationOptions 中使用静态。
class Page1 extends Component {
constructor(){
super();
this.state = {
isCollapsed:false
}
}
static navigationOptions = {
drawerLabel: () => (
<View style={{
flexDirection:'row',
alignItems:'center',
justifyContent:'space-around',
width:'100%'
}}>
<Text>Page 1</Text>
<TouchableOpacity
activeOpacity={0.9}
onPress={() => this.setState({isCollapsed:!this.state.isCollapsed})}
>
<Icon
name='plus'
type='entypo'
/>
</TouchableOpacity>
<Collapsible collapsed={this.state.isCollapsed}>
<Text>Items...</Text>
</Collapsible>
</View>
),
};
render(){
return(
<View>
<Text>Page 1</Text>
</View>
)
}
}
【问题讨论】:
标签: reactjs react-native ecmascript-6