博客
关于我
element-ui 月份选择器,选择月份获取当前月的第一天和最后一天
阅读量:212 次
发布时间:2019-03-01

本文共 564 字,大约阅读时间需要 1 分钟。

changeMonth(value) {      let date = new Date(value);      let month = (date.getMonth() + 1).toString().padStart(2, '0');      let year = date.getFullYear();      let startTime = year + '' + month + '01';      let day = new Date(year, month, 0);      let endTime = year + '' + month + '' + day.getDate();      console.log(startTime, 'startTime');      console.log(endTime, 'endTime');    }
该代码实现了月份选择器的功能,通过v-model绑定日期值并设置类型为月份,用户可通过该组件选择任意月份。 在changeMonth函数中,首先创建日期对象,获取月份并补充前导零,获取年份,计算起始时间和结束时间。 起始时间格式为"yyyyMM01",结束时间格式为"yyyyMMdd"。 通过console.log输出起始时间和结束时间以供调试。

转载地址:http://xuzv.baihongyu.com/

你可能感兴趣的文章
npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
查看>>
npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
查看>>
npm和yarn的使用对比
查看>>
npm报错unable to access ‘https://github.com/sohee-lee7/Squire.git/‘
查看>>
npm的问题:config global `--global`, `--local` are deprecated. Use `--location=global` instead 的解决办法
查看>>
NR,NF,FNR
查看>>
nrf开发笔记一开发软件
查看>>
NSDateFormatter的替代方法
查看>>
NSOperation基本操作
查看>>
NSSet集合 无序的 不能重复的
查看>>
NT AUTHORITY\NETWORK SERVICE 权限问题
查看>>
ntko文件存取错误_苹果推送 macOS 10.15.4:iCloud 云盘文件夹共享终于来了
查看>>
nullnullHuge Pages
查看>>
numpy 用法
查看>>
Numpy如何使用np.umprod重写range函数中i的python
查看>>
oauth2-shiro 添加 redis 实现版本
查看>>
OAuth2.0_JWT令牌-生成令牌和校验令牌_Spring Security OAuth2.0认证授权---springcloud工作笔记148
查看>>
OAuth2.0_JWT令牌介绍_Spring Security OAuth2.0认证授权---springcloud工作笔记147
查看>>
OAuth2.0_介绍_Spring Security OAuth2.0认证授权---springcloud工作笔记137
查看>>
OAuth2.0_完善环境配置_把资源微服务客户端信息_授权码存入到数据库_Spring Security OAuth2.0认证授权---springcloud工作笔记149
查看>>