From e7d4ea634d00b46c1cc67d3890f029230dd6c812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=B0=E4=BA=9A=E5=B0=94-IT?= <136627746+Diyar-IT@users.noreply.github.com> Date: Mon, 14 Oct 2024 09:35:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(laydate):=20=E5=A2=9E=E5=8A=A0=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=B8=BAdate=E6=88=96=E8=80=85datetime=E6=97=B6?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=B9=B4=E5=88=97=E8=A1=A8=E6=8D=A2=E5=88=B0?= =?UTF-8?q?=E6=9C=88=E9=80=89=E6=8B=A9=E5=99=A8=E5=8A=9F=E8=83=BD=20(#2235?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/laydate.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/modules/laydate.js b/src/modules/laydate.js index 8cfed9cb..5e195107 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -514,9 +514,9 @@ }(), function(){ //年月选择 var elem = lay.elem('div', { "class": 'laydate-set-ym' - }), spanY = lay.elem('span'), spanM = lay.elem('span'); - elem.appendChild(spanY); - elem.appendChild(spanM); + }); + elem.appendChild(lay.elem('span')); + elem.appendChild(lay.elem('span')); return elem; }(), function(){ //下一月 var elem = lay.elem('i', { @@ -1788,13 +1788,14 @@ } //当为年选择器或者年月选择器 - var isYearOrMonth = options.type === 'year' || options.type === 'month'; - if(isYearOrMonth){ + var isYearOrMonth = ['year', 'month'].indexOf(options.type) !== -1; + var isChangeMonth = type === 'year' && ['date', 'datetime'].indexOf(options.type) !== -1; + if (isYearOrMonth || isChangeMonth) { lay(ul).find('.'+ THIS).removeClass(THIS); lay(this).addClass(THIS); //如果为年月选择器,点击了年列表,则切换到月选择器 - if(options.type === 'month' && type === 'year'){ + if ((options.type === 'month' && type === 'year') || isChangeMonth) { that.listYM[index][0] = ym; isAlone && ((index ? that.endDate : dateTime).year = ym); that.list('month', index);