From 6d64dae1a82ab48287364160756141100ba7fcf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=85=AE?= <9151335+xiqinyan@user.noreply.gitee.com> Date: Fri, 8 Jul 2022 08:02:58 +0000 Subject: [PATCH] =?UTF-8?q?update=20docs/component/picker-view.md.=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=9B=91=E5=90=AC=E4=BA=8B=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E4=BB=A5=E5=89=8D=E6=B2=A1=E6=9C=89=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=88=B0=EF=BC=8C=E7=9B=91=E5=90=AC=E5=88=B0=E6=AF=8F?= =?UTF-8?q?=E4=B8=AA=E6=9C=88=E7=9A=84=E6=97=B6=E9=97=B4=EF=BC=88=E4=BE=8B?= =?UTF-8?q?=E5=A6=822=E6=9C=88=E6=9C=8931=E5=A4=A9=20=E8=BF=99=E6=98=AF?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E6=98=BE=E7=A4=BA=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=89=EF=BC=8C=E5=B7=B2=E5=91=8A=E7=9F=A5=E6=94=B9=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/component/picker-view.md | 74 ++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/docs/component/picker-view.md b/docs/component/picker-view.md index 762bb2184..ac9593d56 100644 --- a/docs/component/picker-view.md +++ b/docs/component/picker-view.md @@ -84,16 +84,86 @@ day, value: [9999, month - 1, day - 1], visible: true, - indicatorStyle: `height: 50px;` + indicatorStyle: `height: 50px;`, + + mouthArr1:[1,3,5,7,8,10,12],//31天的数据 + mouthArr2:[4,6,9,11],//30天的数据 } }, + //2022-07-08新增监听事件,因为以前没有判断到,监听到每个月的时间----------> + watch: { + year: { + // 数据发生变化就会调用这个函数 + handler(newVal) { + this.showDate() + }, + // 立即处理 进入页面就触发 + immediate: true + }, + month:{ + // 数据发生变化就会调用这个函数 + handler(newVal) { + this.showDate() + }, + // 立即处理 进入页面就触发 + immediate: true + } + }, + //--------------------------------> methods: { bindChange: function (e) { const val = e.detail.value this.year = this.years[val[0]] this.month = this.months[val[1]] this.day = this.days[val[2]] - } + + //由于判断太多建议封装成组件形式,将值通过emit子传父 + /*let obj = { + year:this.year, + month:this.month, + day:this.day, + }*/ + //this.$emits('事件名',obj)即可 + }, + // 判断修改显示数据2022-07-08 + showDate(){ + if (this.year % 4 == 0 && this.year % 100 != 0 || this.year % 400 == 0) { + if(this.month === 2){ + this.days = [] + for (let i = 1; i <= 29; i++) { + this.days.push(i) + } + }else if(this.mouthArr1.includes(this.month)){ + this.days = [] + for (let i = 1; i <= 31; i++) { + this.days.push(i) + } + }else if(this.mouthArr2.includes(this.month)){ + this.days = [] + for (let i = 1; i <= 30; i++) { + this.days.push(i) + } + } + } else { + if(this.month === 2){ + this.days = [] + for (let i = 1; i <= 28; i++) { + this.days.push(i) + } + }else if(this.mouthArr1.includes(this.month)){ + this.days = [] + for (let i = 1; i <= 31; i++) { + this.days.push(i) + } + }else if(this.mouthArr2.includes(this.month)){ + this.days = [] + for (let i = 1; i <= 30; i++) { + this.days.push(i) + } + } + } + } //showDate + } } -- Gitee