声明一个顶部导航栏View
<
View
style
=
{
styles
.
container
}
>
<
View
style
=
{{
flex:
1
}}
></
View
>
<
View
style
=
{{
flex:
1
,
flexDirection:
'row'
}}
>
<
View
style
=
{{
flex:
1
}}
>
<
Text
style
=
{{
alignSelf :
'flex-start'
,
height:
44
,
marginLeft:
8
}}
>
管理员
</
Text
>
</
View
>
<
View
style
=
{{
flex:
1
,
flexDirection:
'row'
,
justifyContent:
'center'
,
alignItems:
'center'
}}
>
<
View
style
=
{{
flex:
4
}}
>
<
Text
onPress
=
{
this
.
props
.
onPressAdress
}
style
=
{{
height:
22
,
textAlign :
'right'
}}
>
this.props.name
</
Text
></
View
>
<
View
style
=
{{
flex:
1
}}
>
<
TouchableHighlight
underlayColor
=
'#FFA54F'
onPress
=
{
this
.
props
.
onPressSetting
}
>
<
Image
style
=
{{
height:
22
,
width:
22
,
alignSelf :
'flex-end'
}}
source
=
{
require
(
'../../res/images/setting.png'
)}
/>
</
TouchableHighlight
></
View
>
<
View
style
=
{{
flex:
0.3
,
width:
5
}}
/>
</
View
>
</
View
>
</
View
>
在使用的时候直接导出这块Component 在另一个界面导入
<
BaseHeadView
onPressAdress
=
{()
=>this
.
props
.
navigation
.
navigate
(
'SingIn'
,{
name:
'总工时:0分钟'
})}
onPressSetting
=
{()
=>
alert
(
'dianji设置'
)}
/>
使用时可直接调用父类的属性来进行赋值,可以介绍一部分的代码量,所有的属性都可以 图片 文字 触发方法
自己摸索,如果不对,谢谢大家前来留言指导。