小程序-农历日期选择器
原生的日期选择只可以选择公元历日期,在一些场景下我们可能需要使用到传统农历,这个插件可以帮助您很好的选择农历日期,同时自带的方法可以做到公历转农历日期。如果有个性化的需求的话可以联系开发者(微信 raymondSATA)
当前版本
当前最新版本是 1.0.0
appid是 wx6ac335896f1078f1
申请小程序插件的使用
请在知晓程序的插件商店申请使用
在小程序中使用本插件
在 app.json
中声明插件
{
"plugins": {
"lunarDatePicker": {
"version": "1.0.0",
"provider": "wx6ac335896f1078f1"
}
}
}
在需要引入的页面的json配置中加入
{
"usingComponents": {
"lunarDatePicker": "plugin://lunarDatePicker/lunarDatePicker"
}
}
在相应的页面的js文件中加入
var plugin = requirePlugin("lunarDatePicker")
Page({
data: {
date: "1998-06-18",
ldate: plugin.date2Lunar("1998-06-18")
},
onLoad: function () {
},
test: function (e) {
console.log(e.detail)
this.setData({
date: e.detail.date,
ldate: e.detail.lunarDate
})
}
})
在相应页面的wxml文件中加入
<lunarDatePicker value="{{date}}" bindpickerchange="test">
当前选择:{{ldate}}
</lunarDatePicker>
编译页面,预览效果
插件方法
date2Lunar
公历日期转化为农历日期,输出的格式为 1998年五月廿四
plugin.date2Lunar("1998-06-18")
组件方法
bindpickerchange
在点击确认的时候触发的方法,返回的event.detail
:
{
date: "1998-06-18",
lunarDate: "1998年五月廿四"
}
Last updated