点击后:
<view class&#61;"item"><view class&#61;"tit">选择时间view><picker class&#61;"picker date" mode&#61;"date" :value&#61;"date" :start&#61;"startDate" :end&#61;"endDate" &#64;change&#61;"bindDateChange"><view>{{ date }}view>picker><picker class&#61;"picker" mode&#61;"time" :value&#61;"timeStart" start&#61;"09:01" end&#61;"21:01" &#64;change&#61;"bindTimeStart"><view class&#61;"uni-input">{{ timeStart }}view>picker>-<picker class&#61;"picker" mode&#61;"time" :value&#61;"timeEnd" start&#61;"09:01" end&#61;"21:01" &#64;change&#61;"bindTimeEnd"><view class&#61;"uni-input">{{ timeEnd }}view>picker>
view>
data() {const currentDate &#61; this.getDate({format: true});return {date: currentDate,timeStart: &#39;14:00&#39;,timeEnd: &#39;16:00&#39;};
},
computed: {startDate() {return this.getDate(&#39;start&#39;);},endDate() {return this.getDate(&#39;end&#39;);}
},
methods: {bindDateChange: function(e) {this.date &#61; e.target.value;},getDate(type) {const date &#61; new Date();let year &#61; date.getFullYear();let month &#61; date.getMonth() &#43; 1;let day &#61; date.getDate();if (type &#61;&#61;&#61; &#39;start&#39;) {year &#61; year - 60;} else if (type &#61;&#61;&#61; &#39;end&#39;) {year &#61; year &#43; 2;}month &#61; month > 9 ? month : &#39;0&#39; &#43; month;day &#61; day > 9 ? day : &#39;0&#39; &#43; day;return &#96;${year}-${month}-${day}&#96;;},bindTimeStart:function(e){this.timeStart &#61; e.target.value;},bindTimeEnd:function(e){this.timeEnd &#61; e.target.value;},
}
picker选择器的用法