美文网首页
js获取系统当前小时展示不同的时间状态

js获取系统当前小时展示不同的时间状态

作者: yuki20 | 来源:发表于2020-03-26 10:30 被阅读0次

    获取系统当前小时展示不同的时间状态

    data(){

    return{

    sayHello:undefined

    }}

    constnow=newDate()

    consthour=now.getHours()

    if(hour<6) {

    this.sayHello='凌晨好'

    }elseif(hour<9) {

    this.sayHello='早上好'

    }elseif(hour<12) {

    this.sayHello='上午好'

    }elseif(hour<14) {

    this.sayHello='中午好'

    }elseif(hour<17) {

    this.sayHello='下午好'

    }elseif(hour<19) {

    this.sayHello='傍晚好'

    }elseif(hour<22) {

    this.sayHello='晚上好'

    }else{

    this.sayHello='夜里好'

    }

    },

    相关文章

      网友评论

          本文标题:js获取系统当前小时展示不同的时间状态

          本文链接:https://www.haomeiwen.com/subject/xypquhtx.html