代码如下:
import {createStackNavigator, createAppContainer, createBottomTabNavigator} from "react-navigation";
import HomeScreen from "../pages/home";
import MineScreen from "../pages/mine";
import DetailsScreen from "../pages/details";
// import React from 'react';
import TabIconBottom from "../components/init/tab_bottom";
const homeNavigator = createStackNavigator(
{
Home: HomeScreen,
Details: DetailsScreen,
}
);
const mineNavigator = createStackNavigator(
{
Mine:MineScreen
}
);
const bottomNavigator = createBottomTabNavigator(
{
TabHome: {
screen:homeNavigator,
navigationOptions:{
tabBarIcon:({title,focused})=>{
return <TabIconBottom/>
}
}
},
TabMine:mineNavigator
},
{
initialRouteName: 'TabHome',
}
);
export default createAppContainer(bottomNavigator);
报错信息:
出错原因:在代码中使用了TabIconBottom,这是jsx语法,必须引入React
解决办法:将头部的注释打开即可
import React from 'react';