Vue3获取阴历/农历日期

安装插件

javascript 复制代码
pnpm add chinese-lunar-calendar

引入阳历/阴历切换函数

javascript 复制代码
import {getLunar} from 'chinese-lunar-calendar'

export function lunarDate(pDate){
    const year = pDate.getFullYear()
    const month = pDate.getMonth() +1
    const day = pDate.getDate()
    const result = getLunar(year,month,day)
    return result.dateStr
}

调用方法

javascript 复制代码
const date = new Date()
const result = lunarDate(date)//十月廿十
相关推荐
eggwyw几秒前
C++深入浅出探索数据结构的原理
开发语言·c++
eggwyw2 分钟前
C++深入浅出讲解希尔排序算法的实现
开发语言·c++
starzy19906 分钟前
Scala Array操作:从定长数组到ArrayBuffer的完整指南
开发语言·后端·scala
读书札记202218 分钟前
Qt UTF-8和UTF-8(BOM)
开发语言·qt
ShineWinsu21 分钟前
对于Qt:QProgressBar常见属性的解析
开发语言·c++·qt·进度条·gui·定时器·qprogressbar
fanruitian23 分钟前
python 机器学习 交叉验证train_test_split 网格搜索GridSearchCV
开发语言·python·机器学习
AlanAshley30 分钟前
无 SIM 卡也能打 110?手机紧急呼叫能力的软硬件技术探究
开发语言·智能手机·php
modelmd35 分钟前
Go 切片、映射常见使用场景
开发语言·后端·golang
dialect_9 小时前
KMP算法
开发语言·c++·算法
jktantan9 小时前
Vue keep-alive 切标签后滚动位置回顶?因为 onDeactivated 里读到的 scrollTop 是 0
前端·javascript·vue.js