当前位置:网站首页>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
}
},
边栏推荐
- MySQL安装与配置
- Typescript
- [today in history] July 2: BitTorrent came out; The commercial system linspire was acquired; Sony deploys Playstation now
- Keras' deep learning practice -- gender classification based on vgg19 model
- 辉芒微IO单片机FT60F010A-URT
- Does pytorch support 32 bits?
- Taiwan Feiling fm8pb513b MCU provides MCU program development product design
- [target tracking] |siamfc
- 松翰SN8P2511 SOP8单片机 可代烧录 提供单片机方案开发 单片机解密
- How to download wechat payment certificate (API certificate)
猜你喜欢

Easyai notes - machine learning

Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package

PFC232-SOP8/14/16应广一级可带烧录程序编带

【历史上的今天】7 月 2 日:BitTorrent 问世;商业系统 Linspire 被收购;索尼部署 PlayStation Now

【Zuul】com. netflix. zuul. exception. ZuulException: Hystrix Readed time out

MySQL -- basic operation of database

好玩的免费GM游戏整理汇总

1288_FreeRTOS中vTaskResume()接口以及中断安全版本接口实现分析

Intelligent hydropower meter energy consumption monitoring cloud platform

Redisson high performance redis distributed lock source code analysis
随机推荐
Development and application case of pms134 scheme of Yingguang single chip microcomputer with original packaging
android之循环定时器实现,实现定Android时缓存清理
Use Zadig to build a continuous delivery platform from 0 to 1
[golang | grpc] use grpc to realize simple remote call
PMS132B单片机TWS数码管蓝牙充电仓方案开发
In Linux, MySQL sets the job task to start automatically
Pms132b single chip microcomputer TWS digital tube Bluetooth charging chamber program development
体验一下阿里云文字识别OCR
售价仅40元,树莓派Pico开发板加入WiFi模块,刚上市就脱销
义隆EM78P153K DIP14单片机 MCU
Laravel文档阅读笔记-Custom Authentication Login And Registration Using Laravel 8
【Golang | gRPC】使用gRPC实现简单远程调用
MySQL -- basic concept of database
Pfc232-sop8/14/16 should be wide-ranging and can be tape programmed with burning program
Explain kubernetes network model in detail
aloam 代码阅读与总结
wps插入图片后使图片完整显示
What should we pay attention to in the development process of Yingguang single chip microcomputer?
Redisson 高性能 Redis 分布式锁源码分析
开发一个禁止删除namespace的控制器