我通过传递一个字符串来调用这样的组件。
<TripsPage
startingPoint={startingPoint}
/>
现在在这个组件中,我有这个标签,
<Item fixedLabel>
<Input/>
</Item>
在前端,当我们打开这个屏幕时,它显然是空的。但我希望 startingPoint
字符串作为默认输入值出现在上面。这可能吗?
你可以使用 TextInput
. 它有一个名为value的属性,你可以通过它给出默认文本。它有一些事件,如 onChangeText
当textInput值发生变化时,它将给我们带来事件。https:/reactnative.devdocstextinput。
<TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
onChangeText={text => onChangeText(text)}
value={props.startingpoint}
/>