Taro button点击切换选中状态

1、引入组件

2、state中设置选中状态

  // button按钮的默认选中,0代表选中
  state = {
    currentIndex: 0
  }
3、设置class的样式,点击更改选中
  selectNew(){
    this.setState({currentIndex:0});
  }
  selectOld(){
    this.setState({currentIndex:1});
  }

猜你喜欢

转载自www.cnblogs.com/duban/p/10478706.html