封装的加减
<li class="number-li"><span class="sub" @click="substract">-</span><span ref="changs" class="num1">{{num}}</span><span class="ad" @click="add">+</span></li>
css:
.number-li span {
display: inline-block;
border: 2px solid rgba(0, 0, 0, 0.1);
width: 25px;
}
.sub{
text-align:center;
}
.num1{
text-align:center;
width: 25px;
height: 25px;
border: 2px solid rgba(0, 0, 0, 0.1);
}
.ad{
text-align:center;
}
data: substract(){
if(this.num<=1)
{
return
}else{
this.num--
}
},add(){
if(this.num>=10)
{
return
}else{
this.num++
}
}