Comments (6)
请具体描述需求,如果选择入住日期,然后再选离店日期,那理论上肯定是可以的,插件有dayClick事件,你可以根据这个事件来实现这个功能。
from calendar.
你好,需求例如日历展示的是2018-01-2018-06,跨度半年,开始日期选择2018-01-3,结束日期选择 2018-04-2,这时候我需要把,1月3号到4月2号期间的日期,标记为选中状态,通过dayClick可以实现么?
from calendar.
首先,目前插件只能最多显示1个月的日历,除非你引入多次。那我们以正常情况只引入一次来看。
事先准备:
page的data字段里面加几个变量:
begin_date, end_date, 初始化为0
操作步骤:
1、展示2018年1月的视图。用户点击1月3日那个,js页面的代码响应dayClick事件,获取点击日期,存入临时变量day中,进行以下判断:
if (begin_date == 0) {
begin_date = day;
} elseif (end_date == 0) {
if (day < begin_date) {
console.log('结束时间不能小于开始时间');
} else {
end_date = day;
}
} else {
console.log('已选择了开始日期和结束日期,请先清空');
}
2、这个时候要么只设置了begin_date,接下来看第3步, 要么begin_date和end_date都设置好了,接下来看第4步。
3、假设只设置了begin_day,那么用户就可以往后切换视图,假设切换到4月,用户点击了4月2日,那么继续第一步的判断逻辑。来设置end_date的值。
4、于是你的begin_date和end_date都设置好了,那么目前页面显示的日历视图的月份你是知道的,那只需在显示的时候,看当前页面月份的日期是否在begin_date到end_date之间,如果是,就设置相应的day_colors数组。
原理大概就这样。
from calendar.
好的,你讲解的很详细.现在遇到一个问题,当我打开show-more-days为true展示下个月或者上个月的日子,这些天的颜色会跟当月天数颜色不同,可否自己修改成同样颜色? 日历默认带上一个和下一月的按钮,这个有样式可以设置成文字么?我现在是通过小程序的wxID来添加的插件,是否需要通过源码导入去修改这些配置!
from calendar.
1、可以的,days-color的month字段设置为prev或next可以自定义非当前月的日期样式
2、按钮没有可以修改成文字的功能,可以隐藏掉,你可以在隐藏掉之后,自己叠加图层放你要的文字
from calendar.
我通过下载你的源码,改了某些功能,谢谢了☺
from calendar.
Related Issues (20)
- 有什么属性点击当前2018九月标题,不弹出选择年月的弹出事件,
- days-color数组项构成 让日历显示下个月 month属性无法生效 HOT 3
- 日历的起始年份(start-date) 日历的结束年份(end-date)设置无效 HOT 3
- 能不能自定义按钮和选中的背景样式图片, HOT 1
- 怎么在日期下面添加文字? HOT 1
- 能不能添加左右滑动的特效啊?
- 日期下面文字配置无效
- VM23276:1 [non-writable] modification of global variable "wx.version" is not allowed when using plugins at app.json.
- 无法支持Promise回调函数 HOT 1
- 有一个坑,要显示日历,必须把addon属性也等于 'lunar' 才行
- days_style设置无效 current 应该只是当前月的20日改变颜色?事实是所有月的的20号都变了 HOT 1
- 点击当前日期设置样式 HOT 2
- 农历日期显示不对
- 希望能加入时间段选择! HOT 1
- 能否将标题得点击事件禁用啊? HOT 1
- days-addon 貌似无效? HOT 2
- 后面相同的日期都会被选中?
- 在具体日期下面如何自定义备忘录?
- 是不是不维护了?想接锅,不知道有没有转让 HOT 1
- 垃圾东西,被拿去坑人了 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from calendar.