1、Vue methods里,执行完相关代码后,给body添加和移除一个click方法,用到了setTimeout
1 openByDrop(e){ 2 this.calendar3.show=true; 3 this.calendar3.left=e.target.offsetLeft+19; 4 this.calendar3.top=e.target.offsetTop+70; 5 6 e.stopPropagation(); 7 window.setTimeout(()=>{ 8 document.addEventListener("click",(e)=>{ 9 this.calendar3.show=false;10 document.removeEventListener("click",()=>{},false);11 },false);12 },1000)13 },
2、
12 左 3 右 46 7 .test1{ 8 width: 200px; 9 height: 40px;10 font-size: 20px;11 line-height: 40px;12 color: #5e7a88;13 }14 .test2{15 width: 14.28571429%;16 float: left;17 text-align: center;18 }19 .test3{20 width: 14.28571429%;21 float: right;22 text-align: center;23 }24 .test4{25 padding-top: 3px;26 font-size: 16px;27 line-height: 40px;28 text-align: center;29 }信息5
备注:行内元素设置了float以后,可以设置width和height,相当于inline-block
3、用new date()获取当月第一天周几和本月天数
//获取本月第一天周几var monthFirst = new Date(myDate.getFullYear(), parseInt(myDate.getMonth()), 1).getDay();//获取本月天数(获取后一个月的0日即前一月的最后一日)var totalDay=(new Date(myDate.getFullYear(), parseInt(myDate.getMonth() + 1), 0)).getDate();