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)//十月廿十
相关推荐
z落落1 小时前
C# WinForm Socket 转串口设备服务器+Modbus CRC16校验+Socket 客户端
服务器·开发语言·c#
小灰灰搞电子7 小时前
Rust+Slint 实现动态消息提示框源码分享
开发语言·后端·rust
传奇开心果编程8 小时前
【Rust入门知识点学与练】第21课:Trait 进阶 Advanced Traits
开发语言·学习·rust
新时代牛马8 小时前
字符设备驱动完整篇:从 cdev_add、file_operations 到chrdev_open 与排障
开发语言·python
swordbob8 小时前
ReentrantLock 与 AQS 完整学习手册
java·开发语言
mayaairi8 小时前
Vue2 生命周期完全指南:从创建到销毁的8个钩子函数
前端·javascript·vue.js
研☆香9 小时前
一个简单的气泡弹窗制作
javascript
白山编程大哥9 小时前
Java OutputStreamWriter 详解:从字符到字节的桥梁
java·开发语言·python
大模型丫丫9 小时前
用 TypeScript、NestJS 和 LangGraph 搭建一个可控的 AI Agent
javascript·人工智能·typescript
IMPYLH9 小时前
HTML 的 <pre> 元素
前端·javascript·html