![](https://img-blog.csdnimg.cn/28494b23fbb5451c8adcadf37bd867ab.png)
<button @click="showHistory" :class="activeColor-1 ? ' actives':'actives1'">历史图表</button>
<button @click="showRealtime" :class="activeColor-2 ? 'actives':'actives1'">实时图</button>
//变量
activeColor-1:true,
activeColor-2:false,
//方法中事件
//历史图表
showHistory() {
this.activeColor-1 = true;
this.activeColor-2 = false;
}
//实时图表
showRealtime() {
this.activeColor-1 = false;
this.activeColor-2 = true;
},
//css样式
.actives {
width: 80px;
height: 30px;
line-height: 30px;
margin-left: 30px;
border: none;
background-color: #0383a7;
box-shadow: 0 0 1px 0px #0383a7;
border-radius: 10px;
color: #fff;
margin-bottom: 20px;
}
.actives1 {
width: 80px;
height: 30px;
line-height: 30px;
border: none;
margin-left: 30px;
background-color: #7e7171;
border-radius: 10px;
color: rgb(235, 222, 222);
margin-left:30px;
}