element 点击切换按钮的颜色


1.html 

   <el-button-group label="时间">
         <el-button  @click="seeHour" :type="buttonhour"  >时</el-button>
         <el-button  @click="seeDay"  :type="buttonday"  >天</el-button>
         <el-button  @click="seeMonth" :type="buttonmonth" >月</el-button>
   </el-button-group>

2.数据

data() {
    return {
      buttonhour:'primary',
      buttonday:'',
      buttonmonth:'',
}
}

 3.方法

seeHour() {
          this.showDay=false;
          this.showHour=true;
          this.showMonth=false;
          this.buttonhour='primary';
          this.buttonday='';
          this.buttonmonth='';
   },
   seeDay() {
          this.showDay=true;
          this.showHour=false;
          this.showMonth=false;
          this.buttonday='primary';
          this.buttonhour='';
          this.buttonmonth='';
   },
   seeMonth() {
         this.showDay=false;
         this.showHour=false;
         this.showMonth=true;
         this.buttonmonth='primary';
         this.buttonday='';
         this.buttonhour='';
   }

  效果:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM