react-native headertitle显示不出来



  • 写了一个小demo:
    import React, {Component} from 'react';
    import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Image,
    Button,
    TouchableOpacity
    } from 'react-native';
    export default class HomePage extends Component {
    static navigationOptions = {
    headerTitle: '首页',
    tabBarLabel: '首页',
    tabBarIcon: ({ tintColor }) => (
    <Image
    source={
    require('../images/cert0.png')
    }
    style={[styles.icon,{tintColor: tintColor}]}// {tintColor: tintColor} 选中的图片和文字颜色
    />
    ),
    headerTitleStyle: {
    alignSelf:'center',
    },
    };
    render(){
    return(
    <Text>精品推荐</Text>
    );
    }

    }
    const styles = StyleSheet.create({
    container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    },
    icon:{
    width:20,
    height:20
    }
    });
    请大家帮忙看看


Log in to reply