当前位置:网站首页>How can you omit a large number of switch statements
How can you omit a large number of switch statements
2022-07-02 18:02:00 【imkaifan】
Before improvement
watch: {
current: {
handler: function(val) {
switch (val) {
case this.$t('hcc_maintenance_driving_time'):
this.statisticsTitle = this.$t('hcc_maintenance_driving_time_statistics');
this.appPararms.VehicleBIType = 0;
break;
case this.$t('hcc_maintenance_driving_distance'):
this.statisticsTitle = this.$t('hcc_maintenance_driving_distance_statistics');
this.appPararms.VehicleBIType = 1;
break;
case this.$t('hcc_maintenance_driving_overspeed'):
this.statisticsTitle = this.$t('hcc_maintenance_driving_overspeed_statistics');
this.appPararms.VehicleBIType = 2;
break;
case this.$t('hcc_maintenance_driving_safety'):
this.statisticsTitle = this.$t('hcc_maintenance_driving_safety_statistics');
this.appPararms.VehicleBIType = 3;
break;
default:
break;
}
},
immediate: true
}
},
After improvement :
data() {
return {
jumpParamsObj: {
[this.$t('hcc_maintenance_driving_time')]: {
statisticsTitle: this.$t('hcc_maintenance_driving_time_statistics'), VehicleBIType: 0},
[this.$t('hcc_maintenance_driving_distance')]: {
statisticsTitle: this.$t('hcc_maintenance_driving_distance_statistics'), VehicleBIType: 1},
[this.$t('hcc_maintenance_driving_overspeed')]: {
statisticsTitle: this.$t('hcc_maintenance_driving_overspeed_statistics'), VehicleBIType: 2},
[this.$t('hcc_maintenance_driving_safety')]: {
statisticsTitle: this.$t('hcc_maintenance_driving_safety_statistics'), VehicleBIType: 3}
}
}
}
watch: {
current: {
handler: function(val) {
this.statisticsTitle = this.jumpParamsObj[val].statisticsTitle;
this.appPararms.VehicleBIType = this.jumpParamsObj[val].VehicleBIType;
},
immediate: true
}
},
边栏推荐
猜你喜欢

Use Zadig to build a continuous delivery platform from 0 to 1
![[golang | grpc] use grpc to realize simple remote call](/img/93/ae6eba2ba65d6e23bd00f45d04a2ed.png)
[golang | grpc] use grpc to realize simple remote call

win10 kms activator

What is the experience of maintaining Wanxing open source vector database
![[target tracking] | data set summary](/img/2f/39a56d8cfb1638697735616b5e0412.png)
[target tracking] | data set summary

Ora-19838 -- restore control files to the standby database

Two pieces of nature a day! Duan Fengfeng, an alumnus of the University of science and technology of China, was the third Chinese winner of the belby medal

一日2篇Nature!中科大校友段镶锋团队纳米材料新成果,曾是贝尔比奖章第三位华人得主...

Mb10m-asemi rectifier bridge mb10m

自定义一个loading指令
随机推荐
My creation anniversary
Use Zadig to build a continuous delivery platform from 0 to 1
515. Find the maximum value in each tree row
应广单片机PMS150/PMC150/PMS150C消费类单片机
Keras深度学习实战——基于VGG19模型实现性别分类
PMS132B单片机TWS数码管蓝牙充电仓方案开发
2 juillet: BitTorrent est sorti; L'acquisition du système commercial linspire; Sony Deployment PlayStation now
使用Zadig从0到1搭建持续交付平台
MySQL进阶-事务及索引
Ora-19838 -- restore control files to the standby database
应广单片机开发调试应注意的问题
Modbus协议通信异常
把xshell連接服務器關掉,運行的jar包就自動停止的解决方案
WPS inserts a picture and displays it completely
PMS150C应广单片机开发案例
Deep understanding of ThreadLocal
【Zuul】com. netflix. zuul. exception. ZuulException: Hystrix Readed time out
MySQL -- basic operation of database
Many scenic spots are temporarily closed due to the typhoon. The provincial culture and tourism department reminds you to pay attention to safety!
Yingguang single chip microcomputer development specification pmc131 with AD chip to detect battery voltage single chip microcomputer sop8/14