Commit 3dd1534b by xuyl

上一个月日期处理

1 parent 584255be
export const nearlyAMonth = {
data(){
return{
defalutStartTime:'',
defalutEndTime:''
data() {
return {
defalutStartTime: '',
defalutEndTime: ''
}
},
created() {
......@@ -11,7 +11,19 @@ export const nearlyAMonth = {
let month = date.getMonth() + 1
let day = date.getDate()
let aheadOfMonth = month == '1' ? '12' : month - 1
this.defalutStartTime = year + '-' + aheadOfMonth + '-' + day
let preDays = this.mGetDate(year, aheadOfMonth)
// let curDays = this.mGetDate(year, month)
this.defalutEndTime = year + '-' + month + '-' + day
if (day > preDays) {
this.defalutStartTime = year + '-' + aheadOfMonth + '-' + preDays
} else {
this.defalutStartTime = year + '-' + aheadOfMonth + '-' + day
}
},
methods: {
mGetDate(year, month) {
let d = new Date(year, month, 0)
return d.getDate()
}
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!