今天放假,自己实现了一个简易版日历,熟悉了下日期对象的基本使用,记录下遇到的难点和报错
- 暂时坚持样式结构交互都自己实现
- 难点
- 获取当前月份总天数
getdate(){
let nexMonth=new Dade().getMonth+1
let d=new Date(new Date,().getFullyear,nexMonth,0);
return d.getDate()
},
2.获取当前月份一号是星期几
//获取当月1号是星期几
getday(){
let nexMonth=new Date().Month;
let d=new Date(new Date().getFullyear,nexMonth,1);
return d.getDay()
},
- 报错点
- 在monuted中调用computed的方法时不可以加括号和参数
//遍历出当月的天数,增加到dates数组中
for (let i=1;i<=this.getdate;i++){
this.dates.push(i)
}
//遍历出当前的1号是星期几,使1号出现在对应的星期几上
for (let i=0; i<this.getday;i++){ </