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)//十月廿十
相关推荐
C++、Java和Python的菜鸟1 小时前
第10章 后端Web进阶(Maven高级)
开发语言·python
其美杰布-富贵-李1 小时前
第 5 篇:Object3D、Group 与场景树
javascript·three.js
神罚天下ET2 小时前
.NET 新增功能系列文章——C# 中的新增功能
开发语言·c#·.net
所愿ღ2 小时前
SSM框架-Spring3
java·开发语言·笔记·spring
影视飓风TIM3 小时前
C++ STL 完整入门笔记[8]:deque 底层原理深度剖析
开发语言·c++·笔记
zmzb01033 小时前
C++课后习题训练记录Day176
开发语言·c++
Rabitebla3 小时前
C++ STL 之 set 详解:从底层红黑树到实际应用
开发语言·数据结构·c++·算法·leetcode
520拼好饭被践踏3 小时前
JAVA+Agent学习day26
java·开发语言·数据结构·学习·agent
157092511343 小时前
优先队列:从Java源码到实战
开发语言·python
jinyishu_4 小时前
C++继承与多态进阶
开发语言·c++·程序人生