当前位置:网站首页>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
}
},
边栏推荐
- Yingguang pmc131 SOP16 16pin eight bit MCU
- [golang | grpc] generate certificates using OpenSSL
- 一个优秀程序员可抵五个普通程序员!
- ASEMI整流桥UMB10F参数,UMB10F规格,UMB10F封装
- Android cycle timer implementation, to achieve fixed Android cache cleaning
- 把xshell連接服務器關掉,運行的jar包就自動停止的解决方案
- Turn off the xshell connection server and the running jar package will stop automatically
- 把xshell连接服务器关掉,运行的jar包就自动停止的解决方案
- Hbuilderx runs to the mobile phone or simulator and prompts that the device is not found
- 如何下载微信支付证书(API证书)
猜你喜欢

Experience Alibaba cloud character recognition OCR

使用Zadig从0到1搭建持续交付平台

Hbuilderx runs to the mobile phone or simulator and prompts that the device is not found
![[golang | grpc] generate certificates using OpenSSL](/img/a6/0c9c80cc24c5f8585051e00e73072f.png)
[golang | grpc] generate certificates using OpenSSL

Pfc232-sop8/14/16 should be wide-ranging and can be tape programmed with burning program

Mysql - opérations de base de la base de données

MySQL -- basic operation of database

Larvel document reading notes custom authentication login and registration using larvel 8

【Golang | gRPC】使用openssl生成证书

finally详解
随机推荐
Easyai notes - deep learning
PMS150C应广单片机开发案例
Larvel document reading notes custom authentication login and registration using larvel 8
Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
Redisson 高性能 Redis 分布式锁源码分析
EdgeNeXt打出了一套混合拳:集CNN与Transformer于一体的轻量级架构
Outsourcing for five years, abandoned
Does pytorch support 32 bits?
No such file or directory: ‘/tmp/tmpxxx/tmpxxx. py‘
[target tracking] | data set summary
[how is the network connected] Chapter 6 requests arrive at the server and respond to the client (end)
Clé de cartographie vimium
Finally detailed explanation
蓝牙技术|物联网的可穿戴设备新工作模式,蓝牙BLE助力新工作模式
PMS132B单片机TWS数码管蓝牙充电仓方案开发
567.字符串中的排列
977. Square of ordered array
Yilong em78p153k dip14 MCU
Design of the multi live architecture in different places of the king glory mall
Atcoder beginer contest 237 VP supplement