ionic-framework - 我正在尝试在 IonSelect multiple 中添加值,但它在反应离子中仅选择一个值
问题描述
我已经添加了下拉字段,我必须在我发送的下拉列表中显示值,但在这个 ionselect 中,它只需要一个下拉值。
const intila={
primary:[""]
}
const[primarySkill,setPrimary]=useState(intila);
const handleChange=(event:any)=>{
primarySkill.primary=event.target.value;
setPrimary(primarySkill);}
const[isSuccess,setSuccess]=useState(false);
const handleSubmit=(event:any)=>{
dispatch(postPrimary())
}
if(customerData.primary.length>0&&!customerData.isLoading&&!isSuccess){
for(var i=0;i<customerData.primary.length;i++){
var primary=customerData.primary[i];
primarySkill.primary.push(primary);
setPrimary(primarySkill); }
setSuccess(true);
console.log(primarySkill);
}
return (
<div>
<IonSelect className="ion-padding" multiple={true} onIonChange={handleChange} value={primarySkill.primary}>
{itemCustomers}
</IonSelect>
<IonButton onClick={handleSubmit}/>
</div>)
postPrimary 有 ["Customer 1","Customer 2"]
itemCustomer 有 [Customer 1,Customer 2,Customer 3,Customer 4,Customer 5[][1]
这里是 UI 的图像视图:[1]:https ://i.stack.imgur.com/RdmYz.png
解决方案
const handleChange=(event:any)=>{
primarySkill.primary = event.detail.value;
setPrimary(primarySkill);
}
为我工作
推荐阅读
- c++ - 延迟后的C ++优化器调用函数
- java - Java - Android 如何将一个类的列表返回到多个类?
- python - 黑条覆盖了我的 matplotlib 图的 x 标签?
- r - 如何解释 h2o.predict() 结果的概率 (p0, p1)
- php - 使用 php 或 bash 从目录中的 yaml 文件中删除 yaml 属性及其定义
- python - 熊猫通过反向补充字符串合并列
- php - 通过分组的两个字段值对数组进行排序
- python - Numpy 拒绝展平二维数组(展平、拆散、重塑、索引都失败)
- android - 即使在 kill-server 之后模拟器运行时,adb 也会重新生成
- javascript - 如何从范围滑块添加两个值以形成单个值