Skip to content

Commit daa2eee

Browse files
committed
feat(datetime-picker): 新增 日期时间显示框支持插槽
1 parent 1ba0eb4 commit daa2eee

File tree

5 files changed

+42
-29
lines changed

5 files changed

+42
-29
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
<uni-section :title="'v-model用法:' + single" type="line"></uni-section>
1717
<view class="example-body">
1818
<uni-datetime-picker v-model="single" />
19+
</view>
20+
<uni-section :title="'插槽用法:' + single" type="line"></uni-section>
21+
<view class="example-body">
22+
<uni-datetime-picker v-model="single">我是一个插槽,点击我</uni-datetime-picker>
1923
</view>
2024
<uni-section :title="'无边框用法:' + single" type="line"></uni-section>
2125
<view class="example-body">

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
<uni-section :title="'v-model用法:' + single" type="line"></uni-section>
1717
<view class="example-body">
1818
<uni-datetime-picker v-model="single" />
19+
</view>
20+
<uni-section :title="'插槽用法:' + single" type="line"></uni-section>
21+
<view class="example-body">
22+
<uni-datetime-picker v-model="single">我是一个插槽,点击我</uni-datetime-picker>
1923
</view>
2024
<uni-section :title="'无边框用法:' + single" type="line"></uni-section>
2125
<view class="example-body">

uni_modules/uni-datetime-picker/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 2.0.8(2021-07-07)
2+
- 新增 日期时间显示框支持插槽
13
## 2.0.7(2021-07-01)
24
- 优化 添加 uni-icons 依赖
35
## 2.0.6(2021-05-22)

uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
<template>
22
<view class="uni-date">
3-
<view class="uni-date-editor--x" :class="{'uni-date-editor--x__disabled': disabled,
3+
<view @click="show">
4+
<slot>
5+
<view class="uni-date-editor--x" :class="{'uni-date-editor--x__disabled': disabled,
46
'uni-date-x--border': border}">
5-
<view v-if="!isRange" class="uni-date-x uni-date-single" @click="show">
6-
<view class="uni-date__icon-logo">
7-
<image class="uni-date-editor--logo" :src="iconBase64" mode=""></image>
8-
</view>
9-
<input class="uni-date__input" type="text" v-model="singleVal" :placeholder="placeholder"
10-
:disabled="true" />
11-
</view>
12-
<view v-else class="uni-date-x uni-date-range" @click="show">
13-
<view class="uni-date__icon-logo">
14-
<image class="uni-date-editor--logo" :src="iconBase64" mode=""></image>
7+
<view v-if="!isRange" class="uni-date-x uni-date-single">
8+
<view class="uni-date__icon-logo">
9+
<image class="uni-date-editor--logo" :src="iconBase64" mode=""></image>
10+
</view>
11+
<input class="uni-date__input" type="text" v-model="singleVal" :placeholder="placeholder"
12+
:disabled="true" />
13+
</view>
14+
<view v-else class="uni-date-x uni-date-range">
15+
<view class="uni-date__icon-logo">
16+
<image class="uni-date-editor--logo" :src="iconBase64" mode=""></image>
17+
</view>
18+
<input class="uni-date__input uni-date-range__input" type="text" v-model="range.startDate"
19+
:placeholder="startPlaceholder" :disabled="true" />
20+
<slot>
21+
<view class="">{{rangeSeparator}}</view>
22+
</slot>
23+
<input class="uni-date__input uni-date-range__input" type="text" v-model="range.endDate"
24+
:placeholder="endPlaceholder" :disabled="true" />
25+
</view>
26+
<view v-show="!disabled && (singleVal || (range.startDate && range.endDate))"
27+
class="uni-date__icon-clear" @click="clear">
28+
<uni-icons type="clear" color="#e1e1e1" size="14"></uni-icons>
29+
</view>
1530
</view>
16-
<input class="uni-date__input uni-date-range__input" type="text" v-model="range.startDate"
17-
:placeholder="startPlaceholder" :disabled="true" />
18-
<slot>
19-
<view class="">{{rangeSeparator}}</view>
20-
</slot>
21-
<input class="uni-date__input uni-date-range__input" type="text" v-model="range.endDate"
22-
:placeholder="endPlaceholder" :disabled="true" />
23-
</view>
24-
<view v-show="!disabled && (singleVal || (range.startDate && range.endDate))" class="uni-date__icon-clear"
25-
@click="clear">
26-
<uni-icons type="clear" color="#e1e1e1" size="14"></uni-icons>
27-
</view>
31+
</slot>
2832
</view>
2933

3034
<view v-show="popup" class="uni-date-mask" @click="close"></view>
@@ -101,7 +105,7 @@
101105
* @tutorial https://ext.dcloud.net.cn/plugin?id=3962
102106
* @property {String} type 选择器类型
103107
* @property {String|Array} value 绑定值
104-
* @property {String} placeholder 单选择时的占位内容
108+
* @property {String} placeholder 单选择时的占位内容
105109
* @property {String} start 起始时间
106110
* @property {String} start 终止时间
107111
* @property {String} start-placeholder 范围选择时开始日期的占位内容
@@ -113,7 +117,7 @@
113117
**/
114118
115119
export default {
116-
name:'UniDatetimePicker',
120+
name: 'UniDatetimePicker',
117121
components: {
118122
calendar,
119123
timePicker
@@ -618,7 +622,7 @@
618622

619623
<style>
620624
.uni-date-x {
621-
display: flex;
625+
display: flex;
622626
flex-direction: row;
623627
align-items: center;
624628
justify-content: center;
@@ -820,5 +824,4 @@
820824
.mr-50 {
821825
margin-right: 50px;
822826
}
823-
824-
</style>
827+
</style>

uni_modules/uni-datetime-picker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "uni-datetime-picker",
33
"displayName": "uni-datetime-picker 日期选择器",
4-
"version": "2.0.7",
4+
"version": "2.0.8",
55
"description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择",
66
"keywords": [
77
"uni-datetime-picker",

0 commit comments

Comments
 (0)