mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-15 11:34:06 +08:00
docs(components): check docs before stable (#5740)
This commit is contained in:
@ -49,8 +49,39 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const loading = ref(false)
|
||||
const currentDate = dayjs().format('YYYY-MM-DD')
|
||||
const currentDate = formatDate(new Date(), 'yyyy-MM-dd')
|
||||
|
||||
function formatDate(date: string | Date, fmt: string) {
|
||||
if (typeof date == 'string') {
|
||||
return date
|
||||
}
|
||||
|
||||
if (!fmt) fmt = 'yyyy-MM-dd hh:mm:ss'
|
||||
|
||||
if (!date || date == null) return null
|
||||
const o = {
|
||||
'M+': date.getMonth() + 1, // 月份
|
||||
'd+': date.getDate(), // 日
|
||||
'h+': date.getHours(), // 小时
|
||||
'm+': date.getMinutes(), // 分
|
||||
's+': date.getSeconds(), // 秒
|
||||
'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
|
||||
S: date.getMilliseconds(), // 毫秒
|
||||
}
|
||||
if (/(y+)/.test(fmt))
|
||||
fmt = fmt.replace(
|
||||
RegExp.$1,
|
||||
`${date.getFullYear()}`.substr(4 - RegExp.$1.length)
|
||||
)
|
||||
for (const k in o) {
|
||||
if (new RegExp(`(${k})`).test(fmt))
|
||||
fmt = fmt.replace(
|
||||
RegExp.$1,
|
||||
RegExp.$1.length === 1 ? o[k] : `00${o[k]}`.substr(`${o[k]}`.length)
|
||||
)
|
||||
}
|
||||
return fmt
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user