我使用了來自 native-base 的 select 組件:
import { Select } from 'native-base';
假資料:
const OgrenciData = [
{key: '3', name: 'Emre', jobTitle: 'Pc', email: 'Emre.Sanli'},
{key: '5', name: 'Harun', jobTitle: 'Pc', email: 'Emre.Sanli'},
];
我的選擇組件是這樣的:
<Select
selectedValue={baskanOgrenci}
minWidth="200"
accessibilityLabel="Giri? Türü"
placeholder="Giri? Türü"
mt={1}
onValueChange={itemValue => setBaskanOgrenci(itemValue)}>
</Select>
我試過從 FlatList 組件復制,但沒有用 :(
如果可能,我希望我的代碼是這樣的:
{({OgrenciData}) => {
return (
<Select.Item
label={OgrenciData.key}
value={OgrenciData.key}
/>
);
}}
uj5u.com熱心網友回復:
我認為您缺少這樣的地圖功能:
{OgrenciData.map(x => {
return (
<Select.Item
label={x.key}
value={x.key}
/>
);
})}
uj5u.com熱心網友回復:
import { Select } from 'native-base';
const OgrenciData = [
{key: '3', name: 'Emre', jobTitle: 'Pc', email: 'Emre.Sanli'},
{key: '5', name: 'Harun', jobTitle: 'Pc', email: 'Emre.Sanli'},
];
<Select
selectedValue={baskanOgrenci}
minWidth="200"
accessibilityLabel="Giri? Türü"
placeholder="Giri? Türü"
mt={1}
onValueChange={itemValue => setBaskanOgrenci(itemValue)}>
</Select>
{OgrenciData.map(x => {
return (
<Select.Item
label={x.key}
value={x.key}
/>
);
})}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/393354.html
