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)//十月廿十
相关推荐
触底反弹3 分钟前
🔥 前端也能玩转 AI 流式输出!从二进制流到打字机效果,一篇讲透
javascript·人工智能·node.js
胡萝卜术12 分钟前
深度重构:Agent Skills——从 Prompt 工程到能力工程
javascript·架构·github
benchmark_cc38 分钟前
如何用 Python + QuantDash 快速构建高胜率“配对交易(Pairs Trading)”策略?
开发语言·人工智能·python·pandas·量化交易·quantdash
程序员无隅2 小时前
Coding Agent 为什么压缩上下文后还能继续工作?上下文模块设计拆解
java·开发语言·数据库
Python+992 小时前
Java 枚举类(Enum)详解:从基础到高级应用
java·开发语言·python
二炮手亮子2 小时前
浅记java线程池
java·开发语言
To_OC2 小时前
从 “卡死半天” 到 “打字机效果”:大模型流式输出前端实现全记录
前端·javascript·llm
rockey6273 小时前
基于AScript的JavaScript脚本语言发布啦
javascript·c#·.net·js·script
zmzb01033 小时前
C++课后习题训练记录Day157
开发语言·c++
dunge20263 小时前
2026年7月最新ChatGPT Plus / Pro 与 Codex:当 AI Agent 最新5.6版本来袭,必须理解事务、幂等与补偿
开发语言·人工智能·python