我正在尝试在本机反应中使用Picker和PickerIOS,并且显示正确,值正确更改,但是我的控制台因与Picker.item和PickerIOS.item有关的错误而崩溃。不完全确定我对此能做些什么,似乎所有进口据我所知都是正确的。
//imports
import React, { Component } from "react";
import {
Text,
View,
ScrollView,
Switch,
TouchableOpacity,
Platform,
TextInput,
Picker,
PickerIOS
} from "react-native";
import styles from "./styles";
import colors from "../../../../Constants/Colors";
import { validateBlank } from "../../../Components/InputValidation/Validate";
import Axios from "axios";
{Platform.select({
ios: (
<PickerIOS
selectedValue={this.state.businessCountry}
itemStyle={{ height: 50, width: 250 }}
onValueChange={(itemValue, itemIndex) => {
this.setState({ businessCountry: itemValue });
}}
>
<PickerIOS.item label="Select your Country" value={null} />
{this.state.countries.map((country, index) => {
return (
<PickerIOS.item
label={country.name}
value={country.name}
key={index}
/>
);
})}
</PickerIOS>
),
android: (
<Picker
selectedValue={this.state.businessCountry}
itemStyle={{ height: 50, width: 250 }}
onValueChange={(itemValue, itemIndex) => {
this.setState({ businessCountry: itemValue });
}}
>
{this.state.countries.map((country, index) => {
return (
<Picker.item
label={country.name}
value={country.name}
key={index}
/>
);
})}
</Picker>
)
})}
控制台中的错误消息,其中有两个与每个选择器相关
答案 0 :(得分:0)
问题仅仅是一个错字。我使用的是Picker.item和PickerIOS.item,而不是Picker.Item和PickerIOS.Item。