如何在本机反应中设置多行标题? [英] How to set multi line header in react native?
本文介绍了如何在本机反应中设置多行标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试将多行标题添加到我的标题中,如下所示:
I try to add a multi line title to my header like this:
Title
Subtitle
我尝试了下面的代码.它不起作用,我收到错误标题必须为字符串或空"
I tried the code below. It doesn't work, I got an error "title must be string or null"
static navigationOptions = ({ navigation }) => {
return {
title:
<View>
<Text>{navigation.getParam('client') }</Text>
<Text>{navigation.getParam('ref') }</Text>
</View>,
我在 github 上关注了这个问题 https://github.com/react-navigation/react-navigation/issues/2430
I followed this issue on github https://github.com/react-navigation/react-navigation/issues/2430
推荐答案
您需要将 title
替换为 headerTitle
以提供自定义组件.
You need to replace title
with headerTitle
in order to provide the Custom Component.
title
属性接受字符串值,而 headerTitle
默认为显示 title
的 Text
组件.
The title
prop accepts string values whereas the headerTitle
defaults to a Text
component that displays the title
.
因此将其用作
static navigationOptions = ({ navigation }) => {
return {
headerTitle: (
<View>
<Text>{navigation.getParam('client')}</Text>
<Text>{navigation.getParam('ref')}</Text>
</View>
)
}
}
这篇关于如何在本机反应中设置多行标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文