Skip to content

Commit e17331a

Browse files
committed
opti: datetime-picker demo
1 parent 0e8ce24 commit e17331a

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

pages/nvue/datetime-picker/datetime-picker.nvue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<text class="example-info">可以同时选择日期和时间的选择器</text>
44
<uni-section :title="'日期用法:' + single" type="line"></uni-section>
55
<view class="example-body">
6-
<uni-datetime-picker v-model="single" start="2021-3-20" end="2021-5-20" />
6+
<uni-datetime-picker type="date" start="2021-3-20" end="2021-5-20" @change="change" />
77
</view>
88
<uni-section :title="'时间戳用法:' + single" type="line"></uni-section>
99
<view class="example-body">
@@ -46,14 +46,11 @@
4646
single: '2021-04-3',
4747
'datetimesingle': '',
4848
range: ['2021-03-8', '2021-4-20'],
49-
datetimerange: ['2021-03-20 20:10:10', '2021-05-10 10:10:10']
49+
datetimerange: ['2021-03-20 20:10:10', '2021-05-10 10:10:10'],
5050
}
5151
},
5252

5353
watch: {
54-
single(newval) {
55-
console.log('单选:', this.single);
56-
},
5754
datetimesingle(newval) {
5855
console.log('单选:', this.datetimesingle);
5956
},
@@ -63,6 +60,13 @@
6360
datetimerange(newval) {
6461
console.log('范围选:', this.datetimerange);
6562
}
63+
},
64+
65+
methods:{
66+
change(e) {
67+
this.single = e
68+
console.log('----change事件:', this.single = e);
69+
}
6670
}
6771
}
6872
</script>

pages/vue/datetime-picker/datetime-picker.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<text class="example-info">可以同时选择日期和时间的选择器</text>
44
<uni-section :title="'日期用法:' + single" type="line"></uni-section>
55
<view class="example-body">
6-
<uni-datetime-picker v-model="single" start="2021-3-20" end="2021-5-20" />
6+
<uni-datetime-picker type="date" start="2021-3-20" end="2021-5-20" @change="change" />
77
</view>
88
<uni-section :title="'时间戳用法:' + single" type="line"></uni-section>
99
<view class="example-body">
@@ -46,14 +46,11 @@
4646
single: '2021-04-3',
4747
'datetimesingle': '',
4848
range: ['2021-03-8', '2021-4-20'],
49-
datetimerange: ['2021-03-20 20:10:10', '2021-05-10 10:10:10']
49+
datetimerange: ['2021-03-20 20:10:10', '2021-05-10 10:10:10'],
5050
}
5151
},
5252
5353
watch: {
54-
single(newval) {
55-
console.log('单选:', this.single);
56-
},
5754
datetimesingle(newval) {
5855
console.log('单选:', this.datetimesingle);
5956
},
@@ -63,6 +60,13 @@
6360
datetimerange(newval) {
6461
console.log('范围选:', this.datetimerange);
6562
}
63+
},
64+
65+
methods:{
66+
change(e) {
67+
this.single = e
68+
console.log('----change事件:', this.single = e);
69+
}
6670
}
6771
}
6872
</script>

0 commit comments

Comments
 (0)