/*! For license information please see 139.1147a1a5.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["139"],{27870:function(s,n,a){"use strict";a.r(n);var t=a("80681");let e=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
\u65F6\u95F4\u9009\u62E9\u5668\uFF0C\u901A\u5E38\u4E0E\u5F39\u51FA\u5C42\u7EC4\u4EF6\u914D\u5408\u4F7F\u7528\u3002
\n\u901A\u8FC7\u4EE5\u4E0B\u65B9\u5F0F\u6765\u5168\u5C40\u6CE8\u518C\u7EC4\u4EF6\uFF0C\u66F4\u591A\u6CE8\u518C\u65B9\u5F0F\u8BF7\u53C2\u8003\u7EC4\u4EF6\u6CE8\u518C\u3002
\nimport { createApp } from 'vue';\nimport { TimePicker } from 'vant';\n\nconst app = createApp();\napp.use(TimePicker);\n
\n\u901A\u8FC7 v-model
\u7ED1\u5B9A\u5F53\u524D\u9009\u4E2D\u7684\u65F6\u95F4\u3002
<van-time-picker v-model="currentTime" title="\u9009\u62E9\u65F6\u95F4" />\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const currentTime = ref(['12', '00']);\n return { currentTime };\n },\n};\n
\n\u901A\u8FC7 columns-type
\u5C5E\u6027\u53EF\u4EE5\u63A7\u5236\u9009\u9879\u7684\u7C7B\u578B\uFF0C\u652F\u6301\u4EE5\u4EFB\u610F\u987A\u5E8F\u5BF9 hour
\u3001minute
\u548C second
\u8FDB\u884C\u6392\u5217\u7EC4\u5408\u3002
\u6BD4\u5982\uFF1A
\n[\'hour\']
\u6765\u5355\u72EC\u9009\u62E9\u5C0F\u65F6\u3002[\'minute\']
\u6765\u5355\u72EC\u9009\u62E9\u5206\u949F\u3002[\'minute\', \'second\']
\u6765\u9009\u62E9\u5206\u949F\u548C\u79D2\u3002[\'hour\', \'minute\', \'second\']
\u6765\u9009\u62E9\u5C0F\u65F6\u3001\u5206\u949F\u548C\u79D2\u3002<van-time-picker\n v-model="currentTime"\n title="\u9009\u62E9\u65F6\u95F4"\n :columns-type="columnsType"\n/>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const currentTime = ref(['12', '00', '00']);\n const columnsType = ['hour', 'minute', 'second'];\n return {\n currentTime,\n columnsType,\n };\n },\n};\n
\n\u4F60\u53EF\u4EE5\u4F7F\u7528 min-hour
\u548C max-hour
\u7B49\u5C5E\u6027\u6765\u9650\u5236\u5C0F\u65F6\uFF08hour\uFF09\u8303\u56F4\u3001\u5206\u949F\uFF08minute\uFF09\u8303\u56F4\u548C\u79D2\uFF08second\uFF09\u8303\u56F4\u3002
\u6BD4\u5982\u4EE5\u4E0B\u793A\u4F8B\uFF0C\u7528\u6237\u53EF\u4EE5\u9009\u62E9\u7684\u5C0F\u65F6\u662F 10 ~ 20
\uFF0C\u5206\u949F\u662F 30 ~ 40
\u3002
<van-time-picker\n v-model="currentTime"\n title="\u9009\u62E9\u65F6\u95F4"\n :min-hour="10"\n :max-hour="20"\n :min-minute="30"\n :max-minute="40"\n/>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const currentTime = ref(['12', '35']);\n return { currentTime };\n },\n};\n
\n\u4F60\u53EF\u4EE5\u4F7F\u7528 min-time
\u548C max-time
\u5C5E\u6027\u6765\u9650\u5236\u6574\u4F53\u65F6\u95F4\u8303\u56F4\uFF0C\u7EA6\u5B9A\u683C\u5F0F 10:00:00
\u3002
min-time
\u540E\uFF0Cmin-hour
\u3001min-minute
\u3001min-second
\u5C5E\u6027\u5C06\u4E0D\u4F1A\u751F\u6548\u3002max-time
\u540E\uFF0Cmax-hour
\u3001max-minute
\u3001max-second
\u5C5E\u6027\u5C06\u4E0D\u4F1A\u751F\u6548\u3002\u6BD4\u5982\u4EE5\u4E0B\u793A\u4F8B\uFF0C\u7528\u6237\u53EF\u4EE5\u9009\u62E9\u4ECE 09:40:10
\u5230 20:20:50
\u7684\u4EFB\u610F\u65F6\u95F4\u3002
<van-time-picker\n v-model="currentTime"\n title="\u9009\u62E9\u65F6\u95F4"\n :columns-type="['hour', 'minute', 'second']"\n min-time="09:40:10"\n max-time="20:20:50"\n/>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const currentTime = ref(['12', '00', '00']);\n return { currentTime };\n },\n};\n
\n\u901A\u8FC7\u4F20\u5165 formatter
\u51FD\u6570\uFF0C\u53EF\u4EE5\u5BF9\u9009\u9879\u7684\u6587\u5B57\u8FDB\u884C\u683C\u5F0F\u5316\u3002
<van-time-picker\n v-model="currentTime"\n title="\u9009\u62E9\u65F6\u95F4"\n :formatter="formatter"\n/>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const currentTime = ref(['12', '00']);\n const formatter = (type, option) => {\n if (type === 'hour') {\n option.text += '\u65F6';\n }\n if (type === 'minute') {\n option.text += '\u5206';\n }\n return option;\n };\n\n return {\n formatter,\n currentTime,\n };\n },\n};\n
\n\u901A\u8FC7\u4F20\u5165 filter
\u51FD\u6570\uFF0C\u53EF\u4EE5\u5BF9\u9009\u9879\u6570\u7EC4\u8FDB\u884C\u8FC7\u6EE4\uFF0C\u5254\u9664\u4E0D\u9700\u8981\u7684\u65F6\u95F4\uFF0C\u5B9E\u73B0\u81EA\u5B9A\u4E49\u65F6\u95F4\u95F4\u9694\u3002
<van-time-picker v-model="currentTime" title="\u9009\u62E9\u65F6\u95F4" :filter="filter" />\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const currentTime = ref(['12', '00']);\n const filter = (type, options) => {\n if (type === 'minute') {\n return options.filter((option) => Number(option.value) % 10 === 0);\n }\n return options;\n };\n\n return {\n filter,\n currentTime,\n };\n },\n};\n
\nfilter
\u51FD\u6570\u7684\u7B2C\u4E09\u4E2A\u53C2\u6570\u80FD\u83B7\u53D6\u5230\u5F53\u524D\u9009\u62E9\u7684\u65F6\u95F4\uFF0C\u8FD9\u5728\u4F7F\u7528\u975E\u53D7\u63A7\u6A21\u5F0F\u65F6\uFF0C\u53EF\u4EE5\u66F4\u7075\u6D3B\u5730\u8FC7\u6EE4\u6389\u4E0D\u9700\u8981\u7684\u65F6\u95F4\u3002
<van-time-picker title="\u9009\u62E9\u65F6\u95F4" :filter="filter" />\n
\nexport default {\n setup() {\n const filter = (type, options, values) => {\n const hour = +values[0];\n\n if (type === 'hour') {\n return options.filter(\n (option) => Number(option.value) >= 8 && Number(option.value) <= 18,\n );\n }\n\n if (type === 'minute') {\n options = options.filter((option) => Number(option.value) % 10 === 0);\n\n if (hour === 8) {\n return options.filter((option) => Number(option.value) >= 40);\n }\n\n if (hour === 18) {\n return options.filter((option) => Number(option.value) <= 20);\n }\n }\n\n return options;\n };\n\n return {\n filter,\n };\n },\n};\n
\n\u53C2\u6570 | \n\u8BF4\u660E | \n\u7C7B\u578B | \n\u9ED8\u8BA4\u503C | \n
---|---|---|---|
v-model | \n\u5F53\u524D\u9009\u4E2D\u7684\u65F6\u95F4 | \nstring[] | \n- | \n
columns-type | \n\u9009\u9879\u7C7B\u578B\uFF0C\u7531 hour \u3001minute \u548C second \u7EC4\u6210\u7684\u6570\u7EC4 | \nstring[] | \n[\'hour\', \'minute\'] | \n
min-hour | \n\u53EF\u9009\u7684\u6700\u5C0F\u5C0F\u65F6 | \nnumber | string | \n0 | \n
max-hour | \n\u53EF\u9009\u7684\u6700\u5927\u5C0F\u65F6 | \nnumber | string | \n23 | \n
min-minute | \n\u53EF\u9009\u7684\u6700\u5C0F\u5206\u949F | \nnumber | string | \n0 | \n
max-minute | \n\u53EF\u9009\u7684\u6700\u5927\u5206\u949F | \nnumber | string | \n59 | \n
min-second | \n\u53EF\u9009\u7684\u6700\u5C0F\u79D2\u6570 | \nnumber | string | \n0 | \n
max-second | \n\u53EF\u9009\u7684\u6700\u5927\u79D2\u6570 | \nnumber | string | \n59 | \n
min-time v4.5.0 | \n\u53EF\u9009\u7684\u6700\u5C0F\u65F6\u95F4\uFF0C\u683C\u5F0F\u53C2\u8003 07:40:00 \uFF0C\u4F7F\u7528\u65F6 min-hour min-minute min-second \u4E0D\u4F1A\u751F\u6548 | \nstring | \n- | \n
max-time v4.5.0 | \n\u53EF\u9009\u7684\u6700\u5927\u65F6\u95F4\uFF0C\u683C\u5F0F\u53C2\u8003 10:20:00 \uFF0C\u4F7F\u7528\u65F6 max-hour max-minute max-second \u4E0D\u4F1A\u751F\u6548 | \nstring | \n- | \n
title | \n\u9876\u90E8\u680F\u6807\u9898 | \nstring | \n\'\' | \n
confirm-button-text | \n\u786E\u8BA4\u6309\u94AE\u6587\u5B57 | \nstring | \n\u786E\u8BA4 | \n
cancel-button-text | \n\u53D6\u6D88\u6309\u94AE\u6587\u5B57 | \nstring | \n\u53D6\u6D88 | \n
show-toolbar | \n\u662F\u5426\u663E\u793A\u9876\u90E8\u680F | \nboolean | \ntrue | \n
loading | \n\u662F\u5426\u663E\u793A\u52A0\u8F7D\u72B6\u6001 | \nboolean | \nfalse | \n
readonly | \n\u662F\u5426\u4E3A\u53EA\u8BFB\u72B6\u6001\uFF0C\u53EA\u8BFB\u72B6\u6001\u4E0B\u65E0\u6CD5\u5207\u6362\u9009\u9879 | \nboolean | \nfalse | \n
filter | \n\u9009\u9879\u8FC7\u6EE4\u51FD\u6570 | \n(type: string, options: PickerOption[], values: string[]) => PickerOption[] | \n- | \n
formatter | \n\u9009\u9879\u683C\u5F0F\u5316\u51FD\u6570 | \n(type: string, option: PickerOption) => PickerOption | \n- | \n
option-height | \n\u9009\u9879\u9AD8\u5EA6\uFF0C\u652F\u6301 px vw vh rem \u5355\u4F4D\uFF0C\u9ED8\u8BA4 px | \nnumber | string | \n44 | \n
visible-option-num | \n\u53EF\u89C1\u7684\u9009\u9879\u4E2A\u6570 | \nnumber | string | \n6 | \n
swipe-duration | \n\u5FEB\u901F\u6ED1\u52A8\u65F6\u60EF\u6027\u6EDA\u52A8\u7684\u65F6\u957F\uFF0C\u5355\u4F4D ms | \nnumber | string | \n1000 | \n
\u4E8B\u4EF6\u540D | \n\u8BF4\u660E | \n\u56DE\u8C03\u53C2\u6570 | \n
---|---|---|
confirm | \n\u70B9\u51FB\u5B8C\u6210\u6309\u94AE\u65F6\u89E6\u53D1 | \n{ selectedValues, selectedOptions, selectedIndexes } | \n
cancel | \n\u70B9\u51FB\u53D6\u6D88\u6309\u94AE\u65F6\u89E6\u53D1 | \n{ selectedValues, selectedOptions, selectedIndexes } | \n
change | \n\u9009\u9879\u6539\u53D8\u65F6\u89E6\u53D1 | \n{ selectedValues, selectedOptions, selectedIndexes, columnIndex } | \n
\u540D\u79F0 | \n\u8BF4\u660E | \n\u53C2\u6570 | \n
---|---|---|
toolbar | \n\u81EA\u5B9A\u4E49\u6574\u4E2A\u9876\u90E8\u680F\u7684\u5185\u5BB9 | \n- | \n
title | \n\u81EA\u5B9A\u4E49\u6807\u9898\u5185\u5BB9 | \n- | \n
confirm | \n\u81EA\u5B9A\u4E49\u786E\u8BA4\u6309\u94AE\u5185\u5BB9 | \n- | \n
cancel | \n\u81EA\u5B9A\u4E49\u53D6\u6D88\u6309\u94AE\u5185\u5BB9 | \n- | \n
option | \n\u81EA\u5B9A\u4E49\u9009\u9879\u5185\u5BB9 | \noption: PickerOption, index: number | \n
columns-top | \n\u81EA\u5B9A\u4E49\u9009\u9879\u4E0A\u65B9\u5185\u5BB9 | \n- | \n
columns-bottom | \n\u81EA\u5B9A\u4E49\u9009\u9879\u4E0B\u65B9\u5185\u5BB9 | \n- | \n
\u901A\u8FC7 ref \u53EF\u4EE5\u83B7\u53D6\u5230 Picker \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\uFF0C\u8BE6\u89C1\u7EC4\u4EF6\u5B9E\u4F8B\u65B9\u6CD5\u3002
\n\u65B9\u6CD5\u540D | \n\u8BF4\u660E | \n\u53C2\u6570 | \n\u8FD4\u56DE\u503C | \n
---|---|---|---|
confirm | \n\u505C\u6B62\u60EF\u6027\u6EDA\u52A8\u5E76\u89E6\u53D1 confirm \u4E8B\u4EF6 | \n- | \n- | \n
getSelectedTime | \n\u83B7\u53D6\u5F53\u524D\u9009\u4E2D\u7684\u65F6\u95F4 | \n- | \nstring[] | \n
\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A
\nimport type { TimePickerProps, TimePickerColumnType } from 'vant';\n
\nTimePickerInstance
\u662F\u7EC4\u4EF6\u5B9E\u4F8B\u7684\u7C7B\u578B\uFF0C\u7528\u6CD5\u5982\u4E0B\uFF1A
import { ref } from 'vue';\nimport type { TimePickerInstance } from 'vant';\n\nconst timePickerRef = ref<TimePickerInstance>();\n\ntimePickerRef.value?.confirm();\n
\n\u53C2\u89C1\u684C\u9762\u7AEF\u9002\u914D\u3002
\n