多个按钮,每次点击的时候只改变一个按钮的状态,有笨办法,但是笨办法写的代码太多了
<a-button :type="type2" class="a1" @click="setMode('PAN')" title="移动(空格键space)" id="2">
<span class="iconfont icon-hand icon"></span>
</a-button>
<a-button class="a1" @click="setMode('DRAWMASK')" title="笔" id="3">
<span class="iconfont icon-shiwu-huabi icon"></span>
</a-button>
<a-button :type="type4" class="a1" @click="setMode('RECT')" title="矩形(Q键)" id="4">
<span class="iconfont icon-huabigongju-juxing icon"></span>
</a-button>
<a-button class="a1" @click="setMode('CIRCLE')" title="圆(W键)" id="5">
<span class="iconfont icon-yuanxing icon"></span>
</a-button>
<a-button :type="type6" class="a1" @click="setMode('POLYGON')" title="多边形(E键)" id="6">
<span class="iconfont icon-duobianxing icon"></span>
</a-button>
笨办法是这样的,要改变span标签的样式,写的代码就更多了
if (mode == 'RECT') {
this.type4 = 'primary'
this.type2 = ''
this.type6 = ''
} else if (mode == 'PAN') {
this.type2 = 'primary'
this.type4 = ''
this.type6 = ''
} else if (mode == 'POLYGON') {
this.type6 = 'primary'
this.type2 = ''
this.type4 = ''
}
笨办法写的代码太多了,有没有什么好的办法