当前位置:网站首页>怎么可以省去大量的switch语句,省去switch语句
怎么可以省去大量的switch语句,省去switch语句
2022-07-02 16:01:00 【imkaifan】
没改良之前
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
}
},
改良后:
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
}
},
边栏推荐
- 第十五章 字符串本地化和消息字典(一)
- Edgenext hit a mixed punch: a lightweight architecture integrating CNN and transformer
- Yingguang single chip microcomputer (MCU popular science)
- 能解决 80% 故障的排查思路
- Ssm+ wechat applet to realize property management system
- ORA-19838 -- 恢复控制文件到备库
- 应广单片机开发 工规 PMC131 带AD芯片检测电池电压单片机SOP8/14
- JDBC
- 台风来袭,多景区暂时关闭,省文旅厅提醒注意安全!
- Are you holding back on the publicity of the salary system for it posts such as testing, development, operation and maintenance?
猜你喜欢
MB10M-ASEMI整流桥MB10M
EdgeNeXt打出了一套混合拳:集CNN与Transformer于一体的轻量级架构
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
Yingguang single chip microcomputer development specification pmc131 with AD chip to detect battery voltage single chip microcomputer sop8/14
Edgenext hit a mixed punch: a lightweight architecture integrating CNN and transformer
如何下载微信支付证书(API证书)
win10 kms activator
wait_for_gap -- 从主库归档备库恢复归档
Easyai notes - machine learning
Virtual lab basic experiment tutorial -7 Polarization (2)
随机推荐
嵌入式开发板 ~ 说明
体验一下阿里云文字识别OCR
Mb10m-asemi rectifier bridge mb10m
Taiwan Feiling fm8pb513b MCU provides MCU program development product design
ORA-19838 -- 恢复控制文件到备库
USB interface powered Bluetooth color light strip controller
辉芒微IO单片机FT60F010A-URT
Solution to the problem that the easycvr kernel of intelligent video analysis platform cannot be started as a service
android之循环定时器实现,实现定Android时缓存清理
List summation [dummy+ tail interpolation + function processing list reference common pit]
Huimang micro IO MCU ft60f11f-mrb
win10 kms activator
[how is the network connected] Chapter 4 explores access networks and network operators
PHP gets the number of days, hours, minutes and seconds between the two timestamps
Experience Alibaba cloud character recognition OCR
RK1126平台项目总结
MySQL --- 数据库的基本操作
王者荣耀商城异地多活架构设计
Ssm+ wechat applet to realize property management system
uva1169