You can use ==
comparator for comparing cid
as shown or use ===
operator and convert your cid
to number:(您可以使用==
比较器比较显示的cid
或使用===
运算符并将cid
转换为数字:)
Using ==(使用==)
const DistrictOptions = Data.DistrictData.filter(x => x.cid == 1).map((v, i) => {
return {
key: i,
value: v.id,
text: v.name
}
});
Using ===(使用===)
const DistrictOptions = Data.DistrictData.filter(x => Number(x.cid, 10) == 1).map((v, i) => {
return {
key: i,
value: v.id,
text: v.name
}
});
You can also use parseInt(x.cid,10)
for a conversion to integer.(您也可以使用parseInt(x.cid,10)
转换为整数。) 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…