获取系统当前小时展示不同的时间状态
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='夜里好'
}
},
网友评论