......
this.state = {
//初始化空数组,表示已经选择的
selectedStores:[],
}
......
handleClick(e){
const newSelection = e.target.value;//拿到点击的具体一项
let newSelectionArray;//新建一个空数组
//判断点击项是否为选择状态,是的话清除选中状态
if(this.state.selectedStores.indexOf(newSelection) > -1) {
newSelectionArray =
this.state.selectedStores.filter((s:any) => s !== newSelection)
} else {
//不是的话就加入新选择数组
newSelectionArray =
[...this.state.selectedStores, newSelection];
}
this.setState({
// 新选择数组统一改为选中状态
selectedStores: newSelectionArray
});
}
arr.indexOf(searchElement) arr.indexOf(searchElement[, fromIndex = 0])
var new_array = arr.filter(callback[, thisArg])
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有