要实现的效果
首先你要有两个图标(可以去插件市场找)
<templete>
<view class="year-box clearfix">
<m-icon type="arrowleft" size="36" class="icon fl" @tap="preYear"></m-icon>
<text class="year fl">{{currentYear}}年</text>
<m-icon type="arrowright fl" size="36" class="icon" @tap="nextYear"></m-icon>
</view>
</templete>
<script>
export default {
data() {
return {
currentYear:21
}
},
methods: {
//上一年
preYear() {
this.currentYear = (Number(this.currentYear) - 1).toString();
console.log(this.currentYear);
this.timeType = 'yearReport';
this.activeIndex = -1;
this.achievePort();
this.salesRinkPort();
},
//下一年
nextYear() {
this.currentYear = (Number(this.currentYear) + 1).toString();
this.timeType = 'yearReport';
this.activeIndex = -1;
this.achievePort();
this.salesRinkPort();
}
}
}
</script>