我正在创建一个React Native应用程序。我尝试使用React Native创建下拉菜单,它对我来说工作得很好。我尝试添加默认选项,如“请选择选项......”。我已经尝试过了,但不起作用。 我的代码是:
<Picker
mode="dropdown"
onValueChange={(itemValue, itemIndex) => this.setState({selectedItem: itemValue})}>
{subchild['OptionValue'].map((subsubchild, Index3)=>
<Picker.Item label={subsubchild['text']} value={subsubchild['id']} />
)}
</Picker>
我尝试过这样做:-
<Picker
mode="dropdown"
onValueChange={(itemValue, itemIndex) => this.setState({selectedItem: itemValue})}> <Picker.Item label="Please select options....." value="0" />
{subchild['OptionValue'].map((subsubchild, Index3)=>
<Picker.Item label={subsubchild['text']} value={subsubchild['id']} />
)}
</Picker>
它不是我想要的那样工作。