安装插件
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)//十月廿十