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)//十月廿十
相关推荐
Y1rong3 小时前
C++ QT之记事本
开发语言·qt
谎言西西里6 小时前
JS 高手必会:手写 new 与 instanceof
javascript
diegoXie7 小时前
Python / R 向量顺序分割与跨步分割
开发语言·python·r语言
程序员小白条7 小时前
0经验如何找实习?
java·开发语言·数据结构·数据库·链表
liulilittle7 小时前
C++ 浮点数封装。
linux·服务器·开发语言·前端·网络·数据库·c++
天问一7 小时前
使用 Vue Router 进行路由定制和调用的示例
前端·javascript·vue.js
失散137 小时前
Python——1 概述
开发语言·python
萧鼎7 小时前
Python 图像哈希库 imagehash——从原理到实践
开发语言·python·哈希算法
小小8程序员8 小时前
STL 库(C++ Standard Template Library)全面介绍
java·开发语言·c++
立志成为大牛的小牛8 小时前
数据结构——五十六、排序的基本概念(王道408)
开发语言·数据结构·程序人生·算法