JSX中通过大括号即可嵌入js; 这里我们通过一个箭头函数和map返回了一个Text的数组,这样我们就通过代码动态生成了N个text的jsx组件对象了。
<
View
>
{
messages.
map((
item,
index)
=>
<
Text
key=
{
index
}
style=
{
styles.
listText
}
>
{
item
}
</
Text
>)
}
<
View
style=
{{
marginTop:
300 }
}
>
<
Button
title=
{this.
props.
content
}
onPress=
{()
=>
this.
props.
navigation.
navigate(
'Profile', {
name:
this.
props.
jumpTitle,
info:
messages })
}
/>
</
View
>
</
View
>