微信小程序-日历
思路分析
要实现一个日历,就需要先知道几个值:
当月有多少天
当月第一天星期几
根据常识我们得知,每月最多31天,最少28天,日历一排7个格子,则会有5排,但若是该月第一天为星期六,则会产生六排格子才对。
小程序没有DOM操作概念,故不能动态的往当月第一天的插入多少个空格子,只能通过在前面加入空格子的循环来控制,具体参考 wxml 文件。
日历模板引入
日历模板面板支持 手势左右滑动;
提供跳转至今天方法jumpToToday;
设置日期待办事项标记 setTodoLabels;
删除指定日期待办事项标记 deleteTodoLabels;
清空所有日期待办事项标记 clearTodoLabels;
提供 template 模板引入
引入wxml及wxss
// example.wxml
<import src="../../template/calendar/index.wxml"/>
<view class="calendar-wrap">
<template is="calendar" data="{{...calendar}}" />
</view>
/* example.wxss */ @import '../../template/calendar/index.wxss';
日历组件初始化
import initCalendar, { getSelectedDay, jumpToToday, setTodoLabels, deleteTodoLabels, clearTodoLabels } from '../../template/calendar/index'; const conf = { onShow: function() { initCalendar({ // multi: true, // 是否开启多选, // disablePastDay: true, // 是否禁选过去日期 /** * 选择日期后执行的事件 * @param { object } currentSelect 当前点击的日期 * @param { array } allSelectedDays 选择的所有日期(当mulit为true时,才有allSelectedDays参数) */ afterTapDay: (currentSelect, allSelectedDays) => { console.log('==============================='); console.log('当前点击的日期', currentSelect); console.log('当前点击的日期是否有事件标记: ', currentSelect.hasTodo || false);
allSelectedDays && console.log('选择的所有日期', allSelectedDays); console.log('getSelectedDay方法', getSelectedDay());
}, /** * 日期点击事件(此事件会完全接管点击事件) * @param { object } currentSelect 当前点击的日期 * @param { object } event 日期点击事件对象 */ // onTapDay(currentSelect, event) { // console.log(currentSelect); // console.log(event); // }, /** * 日历初次渲染完成后触发事件,如设置事件标记 */ afterCalendarRender() { setTodoLabels({
pos: 'bottom',
dotColor: '#40',
days: [{
year: 2018,
month: 5,
day: 12,
}, {
year: 2018,
month: 5,
day: 15,
}],
});
},
});
}, deleteTodo() { // 指定需要删除待办标识的日期 deleteTodoLabels([{
year: 2018,
month: 5,
day: 12,
}, {
year: 2018,
month: 5,
day: 15,
}]); // clearTodoLabels(); }, /** * 跳转至今天 */ jump() { jumpToToday();
},
}; Page(conf);
本站所有资源均由网友贡献或各大下载网站转载。请自行检查软件的完整性!本站所有资源仅供学习参考。请不要将它们用于商业目的。否则,一切后果由您负责!如有侵权,请联系我们删除。联系方式:admin@php.cn
相关文章

08 Feb 2022
微信小程序可用的开发工具:1、“即速应用”,是一个无需代码一键生成的微信小程序开发工具;2、“Coolsite360”,一款微信小程序可视化设计工具;3、“知晓云”;4、微信官方小程序开发工具。

02 Sep 2020
开通微信附近小程序的方法:首先进入微信小程序平台,找到附近的小程序;然后点击“开通”,并进行身份确认;接着服务类目的,选择小程序对应的服务类目;最后等待审核即可。

27 Mar 2020
找到新版微信小程序的方法:1、进入微信“设置”,然后点击下方“通用”。2、在通用中进入“发现管理页”,在发现管理页中开启小程序。然后在微信发现页即可直接找到“小程序”入口。

22 Jun 2018
这篇文章主要介绍了微信小程序tabBar用法,结合实例形式详细分析了微信小程序中tabBar的功能、配置项使用方法与操作注意事项,并附带完整demo源码供读者下载参考,需要的朋友可以参考下

07 Apr 2020
禁止微信小程序游戏的方法:首先打开手机,打开微信,点击【我】;然后点击【设置】,并点击【通用】;接着点击【发现页管理】,并将小程序的开关向左滑动;最后点击小程序关闭按钮即可禁止微信小程序游戏。

30 Apr 2020
有3种情况会导致微信小程序打开来会黑屏:1、微信小程序内部程序出错,导致微信小程序黑屏;2、服务器访问速度慢,导致微信小程序黑屏;3、微信版本过低导致微信小程序无法运行,所以打开来会黑屏。

16 Mar 2020
自己开通微信小程序的方法:首先打开微信公众平台,登录自己的微信小程序;然后进入【管理】,选择要用的小程序模板;接着点击【进入】,把菜单栏里面的信息都填充好;最后设置好服务器域名即可。

26 Aug 2020
区别:微信小店的功能比较少,只拥有基本的商城购物功能,没有营销功能,因而只适合不需要营销推广的个人开店;而小程序则是支持各种功能开发,可以开发商城小程序,也可以开发各种营销推广功能,能够满足商家的多功能需求,因而更具有实用性。

04 Jun 2020
微信小程序的wxss、阿里旗下淘宝、支付宝小程序的acss等等语法很类似原生css,但是在web开发里用惯了动态css语言,再写回原生css很不习惯,尤其是父子样式的嵌套写法非常繁琐。


Hot Tools

微信小程序demo:仿商城
微信小程序demo:仿商城,上手简单,对商城的一些基本的功能有很好的涉及

外卖:实现类似锚点功能
正是大家需要的类似锚点功能,另外也实现了一些外卖app的典型点菜功能,推荐学习研究;

微信小程序demo:乐助
微信小程序demo:乐助:类似基于地理位置的到位;助人应用,与张小龙的小程序精神有点相似。

微信小程序游戏类demo挑选不同色块
微信小程序游戏类demo挑选不同色块

微信小程序demo:轮播图变换
轮播图样式变换,简单的一个用小程序实现的轮播图,写法容易
