Skip to content

Commit

Permalink
下一个月的功能开发中
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoust committed Aug 6, 2018
1 parent 1a66f07 commit 8ca09b9
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions datepicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
var date = new Date();
this.dateOpt = {
_year: date.getFullYear(),
_month: date.getMonth()
_month: date.getMonth(),
_date: date.getDate(),
}
// 存储页面存在的calendar对象
this.calendars = {};
Expand Down Expand Up @@ -161,10 +162,27 @@
},
set: function(newVal) {
if (newVal === this._month) return;
this._month = newVal;
if (newVal >= 12) {
this.year++;
this._month = newVal % 12;
} else this._month = newVal;
console.log(newVal, 'month change');
self.render();
}
})
Object.defineProperty(this.dateOpt, 'date', {
get: function() {
return this._date;
},
set: function(newVal) {
if (newVal === this._date) return;
console.log(new Date(this.year,this.month+1,0))
if (newVal > new Date(this.year,this.month+1,0).getDate()) {
this._date = 1;
this.month++;
}
}
})

document.addEventListener('click', function(e) {
var target = e.target;
Expand All @@ -177,6 +195,10 @@
}, false);
},
render: function() {
console.log(333)
console.log(Calendar.Target.querySelector('.ant-calendar-month-select'), 'innerhte');

Calendar.Target.querySelector('.ant-calendar-month-select').innerHTML = this.dateOpt.month + 1 + '月';
Calendar.Target.querySelector('tbody').innerHTML = this.getTemplate();
},
getTemplate: function() {
Expand Down Expand Up @@ -240,4 +262,11 @@

var calendar = new Calendar({
classN: 'calendar-item'
});
});


// todo:
/*
1.下一月到换年的时候有bug
*/

0 comments on commit 8ca09b9

Please sign in to comment.