DatePicker: update docs for default-time (#9335)

pull/9343/head
杨奕 2018-01-18 15:35:31 +08:00 committed by FuryBean
parent aaf6e7e815
commit e99c12ca04
6 changed files with 185 additions and 81 deletions

View File

@ -65,8 +65,7 @@
value9: '',
value10: '',
value11: '',
value12: '',
value13: ''
value12: []
};
}
};
@ -311,6 +310,7 @@ If type is `daterange`, `default-value` sets the left side calendar.
<el-date-picker
v-model="value9"
type="daterange"
align="right"
start-placeholder="Start Date"
end-placeholder="End Date"
default-value="2010-10-01">
@ -331,33 +331,21 @@ If type is `daterange`, `default-value` sets the left side calendar.
```
:::
### Default start & end time value
### Default time for start date and end date
When picking date range on the date panel with type `datetimerange`, `00:00:00` will be used as the default time value for start & end date. We can control it with option `default-time`.
When picking a date range, you can assign the time part for start date and end date.
`default-time` accepts an array of string. The first item controls time value of the start date and the second item controls time value of the end date.
:::demo
:::demo By default, the time part of start date and end date are both `00:00:00`. Setting `default-time` can change their time respectively. It accepts an array of up to two strings with the format of `12:00:00`. The first string sets the time for the start date, and the second for the end date.
```html
<template>
<div class="block">
<span class="demonstration">start date time 12:00:00</span>
<p>Component value{{ value12 }}</p>
<el-date-picker
v-model="value12"
type="datetimerange"
start-placeholder="Start Date"
end-placeholder="End Date"
:default-time="['12:00:00']">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">start date time 12:00:00, end date time 08:00:00</span>
<el-date-picker
v-model="value13"
type="datetimerange"
start-placeholder="Start Date"
end-placeholder="End Date"
:default-time="['12:00:00', '08:00:00']">
type="daterange"
start-placeholder="Start date"
end-placeholder="End date"
:default-time="['00:00:00', '23:59:59']">
</el-date-picker>
</div>
</template>
@ -366,8 +354,7 @@ When picking date range on the date panel with type `datetimerange`, `00:00:00`
export default {
data() {
return {
value12: '',
value13: ''
value12: []
};
}
};
@ -440,7 +427,7 @@ This feature is at alpha stage. Feedback welcome.
| picker-options | additional options, check the table below | object | — | {} |
| range-separator | range separator | string | — | '-' |
| default-value | optional, default date of the calendar | Date | anything accepted by `new Date()` | — |
| default-time | optional, the time value to use when select datetime range in date table (type `datetimerange`) | string[] | Array with length 2, each item is a string like `12:00:00`. The first item for the start datetime and then second item for the end datetime | — |
| default-time | optional, the time value to use when selecting date range | string[] | Array with length 2, each item is a string like `12:00:00`. The first item for the start date and then second item for the end date | — |
| value-format | optional, format of binding value. If not specified, the binding value will be a Date object | string | year `yyyy`, month `MM`, day `dd`, hour `HH`, minute `mm`, second `ss`, AM/PM `A` | — |
| name | same as `name` in native input | string | — | — |
| unlink-panels | unlink two date-panels in range-picker | boolean | — | false |

View File

@ -56,17 +56,7 @@
value3: new Date(),
value4: '',
value5: '',
value6: '',
value7: '',
value8: '',
value9: '',
value10: '',
value11: '',
value12: '',
value13: '',
value14: '',
value15: '',
value16: ''
value6: ''
};
}
};
@ -234,6 +224,47 @@ DateTimePicker is derived from DatePicker and TimePicker. For a more detailed ex
```
:::
### Default time value for start date and end date
:::demo When picking date range on the date panel with type `datetimerange`, `00:00:00` will be used as the default time value for start and end date. We can control it with the `default-time` attribute. `default-time` accepts an array of up to two strings. The first item controls time value of the start date and the second item controls time value of the end date.
```html
<template>
<div class="block">
<span class="demonstration">Start date time 12:00:00</span>
<el-date-picker
v-model="value5"
type="datetimerange"
start-placeholder="Start Date"
end-placeholder="End Date"
:default-time="['12:00:00']">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">Start date time 12:00:00, end date time 08:00:00</span>
<el-date-picker
v-model="value6"
type="datetimerange"
align="right"
start-placeholder="Start Date"
end-placeholder="End Date"
:default-time="['12:00:00', '08:00:00']">
</el-date-picker>
</div>
</template>
<script>
export default {
data() {
return {
value5: '',
value6: ''
};
}
};
</script>
```
:::
### Attributes
| Attribute | Description | Type | Accepted Values | Default |
|---------- |-------------- |---------- |-------------------------------- |-------- |
@ -253,6 +284,7 @@ DateTimePicker is derived from DatePicker and TimePicker. For a more detailed ex
| picker-options | additional options, check the table below | object | — | {} |
| range-separator | range separator | string | - | '-' |
| default-value | optional, default date of the calendar | Date | anything accepted by `new Date()` | — |
| default-time | the time value to use when selecting date range | string[] | Array with length 2, each item is a string like `12:00:00`. The first item for the start date and then second item for the end date | — |
| value-format | optional, format of binding value. If not specified, the binding value will be a Date object | string | year `yyyy`, month `MM`, day `dd`, hour `HH`, minute `mm`, second `ss`, AM/PM `A` | — |
| name | same as `name` in native input | string | — | — |
| unlink-panels | unllink two date-panels in range-picker | boolean | — | false |

View File

@ -64,7 +64,8 @@
value8: '',
value9: '',
value10: '',
value11: ''
value11: '',
value12: []
};
}
};
@ -310,6 +311,7 @@ Si el tipo es `daterange`, `default-value` establece el calendario del lado izqu
<el-date-picker
v-model="value9"
type="daterange"
align="right"
start-placeholder="Start Date"
end-placeholder="End Date"
default-value="2010-10-01">
@ -330,6 +332,37 @@ Si el tipo es `daterange`, `default-value` establece el calendario del lado izqu
```
:::
### Default time for start date and end date
When picking a date range, you can assign the time part for start date and end date.
:::demo By default, the time part of start date and end date are both `00:00:00`. Setting `default-time` can change their time respectively. It accepts an array of up to two strings with the format of `12:00:00`. The first string sets the time for the start date, and the second for the end date.
```html
<template>
<div class="block">
<p>Component value{{ value12 }}</p>
<el-date-picker
v-model="value12"
type="daterange"
start-placeholder="Start date"
end-placeholder="End date"
:default-time="['00:00:00', '23:59:59']">
</el-date-picker>
</div>
</template>
<script>
export default {
data() {
return {
value12: []
};
}
};
</script>
```
:::
### Formato del valor
De forma predeterminada, DatePicker emite el objet `Date`. Puede utilizar `value-format` para designar el formato del valor emitido, acepta la misma cadena de formato del atributo `format`.
@ -395,6 +428,7 @@ Esta característica está en la etapa alfa. Feedback bienvenido.
| picker-options | opciones adicionales, chequee la tabla debajo | object | — | {} |
| range-separator | separador de rangos | string | — | '-' |
| default-value | opcional, valor por defecto para el calendario | Date | cualquiera aceptado por `new Date()` | — |
| default-time | optional, the time value to use when selecting date range | string[] | Array with length 2, each item is a string like `12:00:00`. The first item for the start date and then second item for the end date | — |
| value-format | opcional, formato del valor enlazado. Si no esta especificado, el valor enlazado será un objeto Date. | string | año `yyyy`, mes `MM`, dia `dd`, hora `HH`, minuto `mm`, segundo `ss` | — |
| name | igual que `name` en el input nativo | string | — | — |
| unlink-panels | desvincular los dos paneles de fecha en el range-picker | boolean | — | false |

View File

@ -56,17 +56,7 @@
value3: new Date(),
value4: '',
value5: '',
value6: '',
value7: '',
value8: '',
value9: '',
value10: '',
value11: '',
value12: '',
value13: '',
value14: '',
value15: '',
value16: ''
value6: ''
};
}
};
@ -235,6 +225,47 @@ DateTimePicker se deriva de DatePicker y TimePicker. Por una explicación más d
```
:::
### Default time value for start date and end date
:::demo When picking date range on the date panel with type `datetimerange`, `00:00:00` will be used as the default time value for start and end date. We can control it with the `default-time` attribute. `default-time` accepts an array of up to two strings. The first item controls time value of the start date and the second item controls time value of the end date.
```html
<template>
<div class="block">
<span class="demonstration">Start date time 12:00:00</span>
<el-date-picker
v-model="value5"
type="datetimerange"
start-placeholder="Start Date"
end-placeholder="End Date"
:default-time="['12:00:00']">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">Start date time 12:00:00, end date time 08:00:00</span>
<el-date-picker
v-model="value6"
type="datetimerange"
align="right"
start-placeholder="Start Date"
end-placeholder="End Date"
:default-time="['12:00:00', '08:00:00']">
</el-date-picker>
</div>
</template>
<script>
export default {
data() {
return {
value5: '',
value6: ''
};
}
};
</script>
```
:::
### Atributos
| Atributos | Descripción | Tipo | Valores aceptados | Por defecto |
| ------------------ | ---------------------------------------- | ----------------- | ---------------------------------------- | ----------- |
@ -254,6 +285,7 @@ DateTimePicker se deriva de DatePicker y TimePicker. Por una explicación más d
| picker-options | opciones adicionales, Comprueba la tabla de mas abajo | object | — | {} |
| range-separator | separador de rango | string | - | '-' |
| default-value | opcional, fecha predeterminada del calendario | Fecha | cualquier cosa aceptada por `new Date()` — | |
| default-time | the time value to use when selecting date range | string[] | Array with length 2, each item is a string like `12:00:00`. The first item for the start date and then second item for the end date | — |
| value-format | opcional, formato de valor de enlazado. Si no se especifica, el valor de enlazado será un objeto Date | cadena | año `yyyy`, mes `MM`, día `dd`, hora `HH`, minuto `mm`, segundo `ss` | — |
| name | igual que `name` en la entrada nativa | string | — | — |
| unlink-panels | desconectar dos date-panels en range-picker | boolean | — | false |

View File

@ -65,8 +65,7 @@
value9: '',
value10: '',
value11: '',
value12: '',
value13: ''
value12: []
};
}
};
@ -306,6 +305,7 @@
<el-date-picker
v-model="value9"
type="daterange"
align="right"
start-placeholder="开始日期"
end-placeholder="结束日期"
default-value="2010-10-01">
@ -328,31 +328,19 @@
### 默认的起始与结束时刻
使用类型`datetimerange`选择时间范围时,在日期选择面板中选定起始与结束的日期,默认会使用该日期的`00:00:00`作为起始与结束的时刻;通过选项`default-time`可以控制选中起始与结束日期时所使用的具体时刻。
在选择日期范围时,指定起始日期和结束日期的默认时刻。
`default-time`接受一个数组,数组每项值为字符串,形如`12:00:00`,其中第一项控制起始日期的具体时刻,第二项控制结束日期的具体时刻。
:::demo
:::demo 选择日期范围时,默认情况下,起始日期和结束日期的时间部分均为当天的 0 点 0 分 0 秒。通过`default-time`可以分别指定二者的具体时刻。`default-time`接受一个数组,其中的值为形如`12:00:00`的字符串,第一个值控制起始日期的时刻,第二个值控制结束日期的时刻。
```html
<template>
<div class="block">
<span class="demonstration">起始日期时刻为 12:00:00</span>
<p>组件值:{{ value12 }}</p>
<el-date-picker
v-model="value12"
type="datetimerange"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['12:00:00']">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">起始日期时刻为 12:00:00结束日期时刻为 08:00:00</span>
<el-date-picker
v-model="value13"
type="datetimerange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['12:00:00', '08:00:00']">
:default-time="['00:00:00', '23:59:59']">
</el-date-picker>
</div>
</template>
@ -361,8 +349,7 @@
export default {
data() {
return {
value12: '',
value13: ''
value12: []
};
}
};
@ -436,7 +423,7 @@
| picker-options | 当前时间日期选择器特有的选项参考下表 | object | — | {} |
| range-separator | 选择范围时的分隔符 | string | — | '-' |
| default-value | 可选,选择器打开时默认显示的时间 | Date | 可被`new Date()`解析 | — |
| default-time | 可选,选择器 type 为 `datetimerange`范围选择选中日期所使用的当日内具体时刻 | string[] | 数组,长度为 2每项值为字符串形如`12:00:00`,第一项指定开始日期的时刻,第二项指定结束日期的时刻,不指定会使用时刻 `00:00:00` | — |
| default-time | 范围选择选中日期所使用的当日内具体时刻 | string[] | 数组,长度为 2每项值为字符串形如`12:00:00`,第一项指定开始日期的时刻,第二项指定结束日期的时刻,不指定会使用时刻 `00:00:00` | — |
| value-format | 可选,绑定值的格式。不指定则绑定值为 Date 对象 | string | 年 `yyyy`,月 `MM`,日 `dd`,小时 `HH`,分 `mm`,秒 `ss`AM/PM `A` | — |
| name | 原生属性 | string | — | — |
| unlink-panels | 在范围选择器里取消两个日期面板之间的联动 | boolean | — | false |

View File

@ -56,17 +56,7 @@
value3: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)],
value4: '',
value5: '',
value6: '',
value7: '',
value8: '',
value9: '',
value10: '',
value11: '',
value12: '',
value13: '',
value14: '',
value15: '',
value16: ''
value6: ''
};
}
};
@ -233,6 +223,47 @@ DateTimePicker 由 DatePicker 和 TimePicker 派生,`Picker Options` 或者其
```
:::
### 默认的起始与结束时刻
:::demo 使用`datetimerange`进行范围选择时,在日期选择面板中选定起始与结束的日期,默认会使用该日期的`00:00:00`作为起始与结束的时刻;通过选项`default-time`可以控制选中起始与结束日期时所使用的具体时刻。`default-time`接受一个数组,数组每项值为字符串,形如`12:00:00`,其中第一项控制起始日期的具体时刻,第二项控制结束日期的具体时刻。
```html
<template>
<div class="block">
<span class="demonstration">起始日期时刻为 12:00:00</span>
<el-date-picker
v-model="value5"
type="datetimerange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['12:00:00']">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">起始日期时刻为 12:00:00结束日期时刻为 08:00:00</span>
<el-date-picker
v-model="value6"
type="datetimerange"
align="right"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['12:00:00', '08:00:00']">
</el-date-picker>
</div>
</template>
<script>
export default {
data() {
return {
value5: '',
value6: ''
};
}
};
</script>
```
:::
### Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
@ -252,6 +283,7 @@ DateTimePicker 由 DatePicker 和 TimePicker 派生,`Picker Options` 或者其
| picker-options | 当前时间日期选择器特有的选项参考下表 | object | — | {} |
| range-separator | 选择范围时的分隔符 | string | - | '-' |
| default-value | 可选,选择器打开时默认显示的时间 | Date | 可被`new Date()`解析 | — |
| default-time | 范围选择时选中日期的默认具体时刻 | string[] | 数组,长度为 2每项值为字符串形如`12:00:00`,第一项指定开始日期的时刻,第二项指定结束日期的时刻,不指定会使用时刻 `00:00:00` | — |
| value-format | 可选,绑定值的格式。不指定则绑定值为 Date 对象 | string | 年 `yyyy`,月 `MM`,日 `dd`,小时 `HH`,分 `mm`,秒 `ss`AM/PM `A` | — |
| name | 原生属性 | string | — | — |
| unlink-panels | 在范围选择器里取消两个日期面板之间的联动 | boolean | — | false |