Taro button點擊切換選中狀態

一、引入組件this

二、state中設置選中狀態3d

  // button按鈕的默認選中,0表明選中
  state = {
    currentIndex: 0
  }
三、設置class的樣式,點擊更改選中
  selectNew(){
    this.setState({currentIndex:0});
  }
  selectOld(){
    this.setState({currentIndex:1});
  }
相關文章
相關標籤/搜索