zoukankan      html  css  js  c++  java
  • js switch 用法

    //获取星期
    //例子1
    var day=new Date().getDay();
    switch (day)
    {
        case 6:
          x="Today it's Saturday";
          break;
        case 0:
          x="Today it's Sunday";
          break;
        default:
          x="Looking forward to the Weekend";
    }

    输出

    "Looking forward to the Weekend"
    //例子2
    var day=new Date().getDay();
    switch (day)
    {
        case 0:
          x="Today it's Sunday";
          break;
        case 1:
          x="Today it's Monday";
          break;
        case 2:
          x="Today it's Tuesday";
          break;
        case 3:
          x="Today it's Wednesday";
          break;
        case 4:
          x="Today it's Thursday";
          break;
        case 5:
          x="Today it's Friday";
          break;
        case 6:
          x="Today it's Saturday";
          break;
    }

    输出

    "Today it's Wednesday"
    //例子3
    switch(t.update_state)
    {
        case 1:
            $('#h-progress-status .value').text("HdwUpdateRestarting")
            break;
        case 2:
            $('#h-progress-status .value').text("HdwUpdateRestartSuccess")
            break;
        case 3:
            $('#h-progress-status .value').text("HdwUpdateRestartFailure")
            break;
        case 11:
            $('#h-progress-status .value').text("HdwUpdateFlashWiping")
            break;
        case 12:
            $('#h-progress-status .value').text("HdwUpdateFlashWipeSuccess")
            break;
        case 13:
            $('#h-progress-status .value').text("HdwUpdateFlashWipeFailure")
            break;
        case 21:
            $('#h-progress-status .value').text("HdwUpdateFlashReprogramming")
            break;
        case 22:
            $('#h-progress-status .value').text("HdwUpdateFlashReprogramSuccess")
            break;
        case 23:
            $('#h-progress-status .value').text("HdwUpdateFlashReprogramFailure")
            break;
        case 31:
            $('#h-progress-status .value').text("HdwUpdateAppStarting")
            break;
        case 32:
            $('#h-progress-status .value').text("HdwUpdateAppStartSuccess")
            break;
        case 33:
            $('#h-progress-status .value').text("HdwUpdateAppStartFailure")
            break;
        default:
          console.log("something else!")
    }
  • 相关阅读:
    2021秋 数分B1笔记
    android逆向奇技淫巧二十三:自己写app调用x音关键so(未完待续)(八)
    android逆向奇技淫巧二十二:ida栈回溯加密算法跟踪(未完待续)(七)
    http tcp websocket
    location.reload
    event.preventDefault
    document.querySelector
    造成播放端卡顿的原因
    引入外部组件 Vue.use()和Vue.component()
    Interpolation
  • 原文地址:https://www.cnblogs.com/sea-stream/p/10765742.html
Copyright © 2011-2022 走看看