App.js
<>
<Router>
<Scene key = 'root'>
<Tabs
key="tabBar"
tabBarComponent={CustomTabBar}
activeTintColor = 'red'
hideNavBar
>
<Scene key="tab1" component={()=><View></View>} title="Tab11"/>
<Scene key="tab2" component={()=><View></View>} title="Tab12"/>
</Tabs>
</Scene>
</Router>
</>
CustomTabBar.js
import React from 'react';
import { Text, View, TouchableOpacity } from 'react-native';
import { Actions } from 'react-native-router-flux';
export default class CustomTabBar extends React.Component {
render() {
const { state } = this.props.navigation;
const activeTabIndex = state.index;
return (
<View style={{flexDirection:'row',justifyContent:"space-around",height:50,alignItems:'center'}}>
{
state.routes.map((element,index) => (
<TouchableOpacity key={element.key} onPress={() => Actions[element.key]()} >
<Text style = {{color:index == activeTabIndex ? this.props.activeTintColor : this.props.inactiveTintColor}}>{element.params.title}</Text>
</TouchableOpacity>
))
}
</View>
);
}
}
请问为什么会报element.params.title是undefined的错误?