react,taro升序降序

 

 // 升序降序
  const [tabs, setTabs] = useState([
    { name: '招募中', sort: -1 },
    { name: '进行中', sort: -1 },
    { name: '已结束', sort: -1 },
    { name: '未成立', sort: -1 }
  ])

  // 招募中
  const handleSortButtomClick = (i: any) => {
    setTabs(
      tabs.map((item, index) => {
        return i === index ? {
          ...item,
          sort: item.sort === -1 ? 0 : Math.abs(item.sort - 1)
        } : {
          ...item,
          sort: -1
        }
      })
    )
  }

{/* 升序降序 */}
            <View className='flex flex-align-item-center flex-justify-content-around sort-box'>
              {tabs.map((i, n) => {
                return <View className='flex my-sort flex-align-item-center' key={n} onClick={() => handleSortButtomClick(n)} >
                  <View className={`sort-text ${i.sort > -1 ? 'active-text' : ''}`}>{i.name}</View>
                  {n === 3 ?
                    '' :
                    <View className='my-sort-item' >
                      <View className={`item-son-top ${i.sort === 0 ? 'active' : ''}`}></View>
                      <View className={`item-son-buttom ${i.sort === 0 || i.sort === -1 ? '' : 'active'}`}></View>
                    </View>
                  }
                </View>
              })}
            </View>

 // 升序降序
.sort-box {
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  max-width: 710px;
  min-width: 710px;
  margin: auto;
  height: 80px;
  background-color: #fff;
  border-bottom: 1px solid #e6e6e6;
  .sort-text {
    font-size: 28px;
    color: #666667;
  }
  .active-text {
    color: #16ba57;
  }
  .my-sort {
    height: 100%;
    .my-sort-item {
      width: 30px;
      display: flex;
      flex-wrap: wrap;
      margin-left: 10px;
      .item-son-top {
        width: 0;
        height: 0;
        border: 12px solid;
        border-color: transparent transparent #e6e6e6 transparent;
        &.active {
          border-color: transparent transparent #16ba57 transparent;
        }
      }
      .item-son-buttom {
        margin-top: 5px;
        width: 0;
        height: 0;
        border: 12px solid;
        border-color: #e6e6e6 transparent transparent transparent;
        &.active {
          border: 12px solid #16ba57;
          border-color: #16ba57 transparent transparent transparent;
        }
      }
    }
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值