可以利用对象来进行映射

比如

      let type = this.radio_value
if (type === 'whole') {
this.time_value = []
} else if (type === 'today') {
this.time_value = [this.getDay(0, '-'), this.getDay(1, '-')]
} else if (type === 'yesterday') {
this.time_value = [this.getDay(-1, '-'), this.getDay(0, '-')]
} else if (type === 'last_seven_days') {
this.time_value = [this.getDay(-7, '-'), this.getDay(0, '-')]
} else if (type === 'last_thirty_days') {
this.time_value = [this.getDay(-30, '-'), this.getDay(0, '-')]
}

可以优化成

      let type = this.radio_value
let map = {
'whole':()=>this.time_value = [],
'today':()=>this.time_value = [this.getDay(0, '-'), this.getDay(1, '-')],
'yesterday':()=>this.time_value = [this.getDay(-1, '-'), this.getDay(0, '-')],
'last_seven_days':()=>this.time_value = [this.getDay(-7, '-'), this.getDay(0, '-')],
'last_thirty_days':()=>this.time_value = [this.getDay(-30, '-'), this.getDay(0, '-')],
}
if(map[type]){
map[type]()
}

最新文章

  1. Windows消息机制
  2. HTML5全屏(Fullscreen)API详细介绍
  3. jquery1.7.2的源码分析(二)
  4. Unity 3D 基础知识方法
  5. 【.Net底层剖析】3.用IL来理解属性
  6. (转) 一步一步学习ASP.NET 5 (一)- 基本概念和环境配置
  7. 重温WCF之消息拦截与篡改(八)
  8. java快速排序详解
  9. homebrew 无法安装提示不能在根目录下使用
  10. wpf研究之道——自定义Button控件
  11. 为什么要使用TypeScript开发Web应用程序
  12. docker网络
  13. Java 多线程之悲观锁与乐观锁
  14. call,apply,bind的用法与区别
  15. Python设计模式 - UML - 用例图(Use Case Diagram)
  16. 【netcore基础】.Net core使用swagger自动生成开发文档
  17. JavaScript中var和this定义变量的区别
  18. 20145118 《Java程序设计》 实验报告四
  19. Office - Excel 2013
  20. CentOS安装oracleJDK

热门文章

  1. java介绍、环境搭建与Hello,World!
  2. 1、Spring源码环境搭建
  3. DataX二次开发——新增HiveReader插件
  4. .NET 团队 更新了 .NET 语言策略
  5. Windows离线安装.net Framework3.5
  6. 数字游戏(NOIP 2003 PJT2)
  7. Windows Server 2016 安装AD和Exchange
  8. 使用GetDIBits()获取Windows位图数据的标准用法,解决内存、堆栈报错问题
  9. SpringMVC的文件、数据校验(Vaildator、Annotation JSR-303)
  10. 大曝光!从RabbitMQ平滑迁移至Kafka架构设计方案!