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)//十月廿十
相关推荐
FRing0342 分钟前
vue3干货总结3(defineOptions(Vue3.3)、defineModel(Vue3.4)、Pinia)
开发语言·前端·vue.js·vue3
whitelbwwww2 小时前
CUDA C++实战--中级
开发语言·前端·c++
FungLeo3 小时前
FengCMS · PHP+MySQL 升级实录 · 内容写入一致性:锁等待超时与跨模型子树删除竞态
开发语言·mysql·php·工程实践·fengcms
inksci3 小时前
用飞帆做了个小网页
前端·javascript·css·html
zhensherlock4 小时前
Protocol Launcher 系列:CodeHub 移动端 GitHub 协作利器
前端·javascript·typescript·node.js·自动化·github·js
谙弆悕博士4 小时前
多智能体架构详解:市场拍卖式架构(Market-based / 竞价协商)
开发语言·架构·去中心化·多智能体·智能体·拍卖架构
ShineWinsu4 小时前
对于Qt:QMessageBox的解析
开发语言·c++·qt·面试·客户端·qmessagebox·消息对话框
承渊政道5 小时前
【Python编程快速上手—让繁琐工作自动化】(列表:把数据排成队,从下标取值到深拷贝)
开发语言·python·pycharm·自动化·列表
tryCbest5 小时前
Python 爬虫从入门到实战(一):基础篇——从零写出第一个爬虫
开发语言·爬虫·python
多加点辣也没关系6 小时前
JavaScript|第40章:JavaScript 工程化实践
开发语言·javascript·ecmascript