当前位置:网站首页>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
}
},
边栏推荐
- 自定义一个loading指令
- Mysql - opérations de base de la base de données
- ASEMI整流桥UMB10F参数,UMB10F规格,UMB10F封装
- 把xshell连接服务器关掉,运行的jar包就自动停止的解决方案
- POJ - 1458 common subsequence (longest common subsequence)
- Huimang micro IO MCU ft60f11f-mrb
- Larvel document reading notes custom authentication login and registration using larvel 8
- MySQL -- basic operation of database
- Unified interface for reading and writing data files in xml/json/ini and ubjson formats
- Chapter 15 string localization and message Dictionary (1)
猜你喜欢
Keras' deep learning practice -- gender classification based on vgg19 model
阿里云子账户 - 权限策略 - 授权给某个账户某个 OSS Bucket 的完全控制权限
一日2篇Nature!中科大校友段镶锋团队纳米材料新成果,曾是贝尔比奖章第三位华人得主...
Aloam code reading and summary
Freemaker+poi realizes dynamic generation and parsing of Excel files
MySQL -- basic operation of database
如何下载微信支付证书(API证书)
【Zuul】com. netflix. zuul. exception. ZuulException: Hystrix Readed time out
Taiwan Feiling fm8pb513b MCU provides MCU program development product design
Viewing technological changes through Huawei Corps (VI): smart highway
随机推荐
1288_FreeRTOS中vTaskResume()接口以及中断安全版本接口实现分析
D构造函数问题
uva1169
MB10M-ASEMI整流桥MB10M
Larvel document reading notes custom authentication login and registration using larvel 8
Atcoder beginer contest 237 VP supplement
把xshell连接服务器关掉,运行的jar包就自动停止的解决方案
Yingguang pmc131 SOP16 16pin eight bit MCU
Mysql - opérations de base de la base de données
php获取两个时间戳之间相隔多少天多少小时多少分多少秒
Clé de cartographie vimium
My creation anniversary
Rk1126 platform project summary
Virtual lab basic experiment tutorial -7 Polarization (2)
MySQL -- basic operation of database
Edgenext hit a mixed punch: a lightweight architecture integrating CNN and transformer
Does pytorch support 32 bits?
辉芒微IO单片机FT60F011A-RB
Explain kubernetes network model in detail
The price is only 40 yuan. Pico development board of raspberry pie is added with WiFi module, and it is out of stock as soon as it comes into the market