关于微信小程序日历插件的使用及步骤
关于微信小程序日历插件的使用及步骤
- 在微信小程序管理后台——设置——第三方服务,按 AppID(wx92c68dae5a8bb046)搜索到该插件并申请授权。
- 在当前小程序的app.json文件中配置插件信息
- 然后在使用该插件的json文件中配置
- 在wxml中引入该插件
5js文件
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
onShow: function () {
var me = this
let demo1_days_style = new Array;
demo1_days_style.push({
month: 'current', day: 10, color: 'red', background:'yellow'
});
// demo1_days_style.push({
// month: 'current', day: 20, color: 'blue', background: 'purple'
// });
me.setData({
style: demo1_days_style
})
console.log(me.data.style,'____')
},
dayClick: function(e){
console.log(e.detail)
},
// 监听下个月点击事件
next:function(e){
console.log(e.detail,"++++")
var me = this
let nextMonth = new Array();
nextMonth.push({
month: 'current', day: 20, color: 'blue', background: 'purple'
})
me.data.style = ''
me.setData({
style: nextMonth
})
},
// 监听上个月的点击事件
prev: function(e){
var me = this ;
let prevMonth = new Array();
prevMonth.push({
month: 'current', day: 10, color: 'red', background: 'yellow'
})
me.data.style = ''
me.setData({
style: prevMonth
})
},
dateChange: function (event) {//监听点击日历标题日期选择器事件
console.log(event.detail);
},
})
补充:客户端可以手动更改日历初始月份,也可以根据服务器端需要更改月份,如果需要在每月显示不同状态的内容,即可以像style数组中添加多个对应状态对象,用户也可以在开发工具的wxml中找到日历对应节点及class属性,在wxss中来修改日历样式
我的微信:957231118 欢迎交流沟通