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)//十月廿十
相关推荐
eggwyw15 小时前
C++深入浅出探索数据结构的原理
开发语言·c++
eggwyw15 小时前
C++深入浅出讲解希尔排序算法的实现
开发语言·c++
starzy199015 小时前
Scala Array操作:从定长数组到ArrayBuffer的完整指南
开发语言·后端·scala
读书札记202215 小时前
Qt UTF-8和UTF-8(BOM)
开发语言·qt
ShineWinsu16 小时前
对于Qt:QProgressBar常见属性的解析
开发语言·c++·qt·进度条·gui·定时器·qprogressbar
fanruitian16 小时前
python 机器学习 交叉验证train_test_split 网格搜索GridSearchCV
开发语言·python·机器学习
AlanAshley16 小时前
无 SIM 卡也能打 110?手机紧急呼叫能力的软硬件技术探究
开发语言·智能手机·php
modelmd16 小时前
Go 切片、映射常见使用场景
开发语言·后端·golang
dialect_1 天前
KMP算法
开发语言·c++·算法
jktantan1 天前
Vue keep-alive 切标签后滚动位置回顶?因为 onDeactivated 里读到的 scrollTop 是 0
前端·javascript·vue.js