当前位置:网站首页>怎么可以省去大量的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
}
},
边栏推荐
- Longest non repeating subarray
- Edgenext hit a mixed punch: a lightweight architecture integrating CNN and transformer
- Experience Alibaba cloud character recognition OCR
- 【网络是怎样连接的】第六章 请求到达服务器以及响应给客户端(完结)
- 每日一题——“水仙花数”
- 外包干了五年,废了...
- MySQL进阶-事务及索引
- 应广PMC131 SOP16 16pin八位单片机
- [today in history] July 2: BitTorrent came out; The commercial system linspire was acquired; Sony deploys Playstation now
- Modbus protocol communication exception
猜你喜欢
Keras深度学习实战——基于VGG19模型实现性别分类
List summation [dummy+ tail interpolation + function processing list reference common pit]
[非线性控制理论]7_High gain and High Frequency
Easyai notes - machine learning
VirtualLab基础实验教程-7.偏振(2)
阿里云子账户 - 权限策略 - 授权给某个账户某个 OSS Bucket 的完全控制权限
VirtualLab基础实验教程-7.偏振(1)
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
【Zuul】com. netflix. zuul. exception. ZuulException: Hystrix Readed time out
随机推荐
Chrome browser quick access stackoverflow
台湾飞凌FM8PB513B单片机提供单片机方案开发 产品设计
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
Larvel document reading notes custom authentication login and registration using larvel 8
Rk1126 platform project summary
Pms132b single chip microcomputer TWS digital tube Bluetooth charging chamber program development
王者荣耀商城异地多活架构设计
Deep understanding of ThreadLocal
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
Atcoder beginer contest 237 VP supplement
MySQL --- 数据库的基本操作
Yilong em78p153k dip14 MCU
Easyai notes - deep learning
把xshell连接服务器关掉,运行的jar包就自动停止的解决方案
Huimang micro IO MCU ft60f010a-urt
Ssm+ wechat applet to realize property management system
VirtualLab基础实验教程-7.偏振(1)
Alibaba cloud sub account - Permission Policy - full control permission granted to an account and an OSS bucket
第十五章 字符串本地化和消息字典(一)
[非线性控制理论]7_High gain and High Frequency