/*! For license information please see 467.47cbf8f7.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["467"],{35909:function(s,n,a){"use strict";a.r(n);var t=a("80681");let l=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
\u63D0\u4F9B\u591A\u4E2A\u9009\u9879\u96C6\u5408\u4F9B\u7528\u6237\u9009\u62E9\uFF0C\u652F\u6301\u5355\u5217\u9009\u62E9\u3001\u591A\u5217\u9009\u62E9\u548C\u7EA7\u8054\u9009\u62E9\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 { Picker } from 'vant';\n\nconst app = createApp();\napp.use(Picker);\n
\nPicker \u7EC4\u4EF6\u901A\u8FC7 columns
\u5C5E\u6027\u914D\u7F6E\u9009\u9879\u6570\u636E\uFF0Ccolumns
\u662F\u4E00\u4E2A\u5305\u542B\u5B57\u7B26\u4E32\u6216\u5BF9\u8C61\u7684\u6570\u7EC4\u3002
\u9876\u90E8\u680F\u5305\u542B\u6807\u9898\u3001\u786E\u8BA4\u6309\u94AE\u548C\u53D6\u6D88\u6309\u94AE\uFF0C\u70B9\u51FB\u786E\u8BA4\u6309\u94AE\u89E6\u53D1 confirm
\u4E8B\u4EF6\uFF0C\u70B9\u51FB\u53D6\u6D88\u6309\u94AE\u89E6\u53D1 cancel
\u4E8B\u4EF6\u3002
<van-picker\n title="\u6807\u9898"\n :columns="columns"\n @confirm="onConfirm"\n @cancel="onCancel"\n @change="onChange"\n/>\n
\nimport { showToast } from 'vant';\n\nexport default {\n setup() {\n const columns = [\n { text: '\u676D\u5DDE', value: 'Hangzhou' },\n { text: '\u5B81\u6CE2', value: 'Ningbo' },\n { text: '\u6E29\u5DDE', value: 'Wenzhou' },\n { text: '\u7ECD\u5174', value: 'Shaoxing' },\n { text: '\u6E56\u5DDE', value: 'Huzhou' },\n ];\n const onConfirm = ({ selectedValues }) => {\n showToast(`\u5F53\u524D\u503C: ${selectedValues.join(',')}`);\n };\n const onChange = ({ selectedValues }) => {\n showToast(`\u5F53\u524D\u503C: ${selectedValues.join(',')}`);\n };\n const onCancel = () => showToast('\u53D6\u6D88');\n\n return {\n columns,\n onChange,\n onCancel,\n onConfirm,\n };\n },\n};\n
\n\u5728\u5B9E\u9645\u573A\u666F\u4E2D\uFF0CPicker \u901A\u5E38\u4F5C\u4E3A\u7528\u4E8E\u8F85\u52A9\u8868\u5355\u586B\u5199\uFF0C\u53EF\u4EE5\u642D\u914D Popup \u548C Field \u5B9E\u73B0\u8BE5\u6548\u679C\u3002
\n<van-field\n v-model="fieldValue"\n is-link\n readonly\n label="\u57CE\u5E02"\n placeholder="\u9009\u62E9\u57CE\u5E02"\n @click="showPicker = true"\n/>\n<van-popup v-model:show="showPicker" round position="bottom">\n <van-picker\n :columns="columns"\n @cancel="showPicker = false"\n @confirm="onConfirm"\n />\n</van-popup>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const columns = [\n { text: '\u676D\u5DDE', value: 'Hangzhou' },\n { text: '\u5B81\u6CE2', value: 'Ningbo' },\n { text: '\u6E29\u5DDE', value: 'Wenzhou' },\n { text: '\u7ECD\u5174', value: 'Shaoxing' },\n { text: '\u6E56\u5DDE', value: 'Huzhou' },\n ];\n const fieldValue = ref('');\n const showPicker = ref(false);\n\n const onConfirm = ({ selectedOptions }) => {\n showPicker.value = false;\n fieldValue.value = selectedOptions[0].text;\n };\n\n return {\n columns,\n onConfirm,\n fieldValue,\n showPicker,\n };\n },\n};\n
\n\u901A\u8FC7 v-model
\u53EF\u4EE5\u7ED1\u5B9A\u5F53\u524D\u9009\u4E2D\u9879\u7684 values
\uFF0C\u4FEE\u6539 v-model
\u7ED1\u5B9A\u7684\u503C\u65F6\uFF0CPicker \u7684\u9009\u4E2D\u72B6\u6001\u4E5F\u4F1A\u968F\u4E4B\u6539\u53D8\u3002
v-model
\u7684\u503C\u662F\u4E00\u4E2A\u6570\u7EC4\uFF0C\u6570\u7EC4\u7684\u7B2C\u4E00\u4F4D\u5BF9\u5E94\u7B2C\u4E00\u5217\u9009\u4E2D\u9879\u7684 value
\uFF0C\u7B2C\u4E8C\u4F4D\u5BF9\u5E94\u7B2C\u4E8C\u5217\u9009\u4E2D\u9879\u7684 value
\uFF0C\u4EE5\u6B64\u7C7B\u63A8\u3002
<van-picker v-model="selectedValues" title="\u6807\u9898" :columns="columns" />\n
\nimport { showToast } from 'vant';\n\nexport default {\n setup() {\n const columns = [\n { text: '\u676D\u5DDE', value: 'Hangzhou' },\n { text: '\u5B81\u6CE2', value: 'Ningbo' },\n { text: '\u6E29\u5DDE', value: 'Wenzhou' },\n { text: '\u7ECD\u5174', value: 'Shaoxing' },\n { text: '\u6E56\u5DDE', value: 'Huzhou' },\n ];\n const selectedValues = ref(['Wenzhou']);\n\n return {\n columns,\n selectedValues,\n };\n },\n};\n
\ncolumns
\u5C5E\u6027\u53EF\u4EE5\u901A\u8FC7\u4E8C\u7EF4\u6570\u7EC4\u7684\u5F62\u5F0F\u914D\u7F6E\u591A\u5217\u9009\u62E9\u3002
<van-picker title="\u6807\u9898" :columns="columns" />\n
\nexport default {\n setup() {\n const columns = [\n // \u7B2C\u4E00\u5217\n [\n { text: '\u5468\u4E00', value: 'Monday' },\n { text: '\u5468\u4E8C', value: 'Tuesday' },\n { text: '\u5468\u4E09', value: 'Wednesday' },\n { text: '\u5468\u56DB', value: 'Thursday' },\n { text: '\u5468\u4E94', value: 'Friday' },\n ],\n // \u7B2C\u4E8C\u5217\n [\n { text: '\u4E0A\u5348', value: 'Morning' },\n { text: '\u4E0B\u5348', value: 'Afternoon' },\n { text: '\u665A\u4E0A', value: 'Evening' },\n ],\n ];\n\n return { columns };\n },\n};\n
\n\u4F7F\u7528 columns
\u7684 children
\u5B57\u6BB5\u53EF\u4EE5\u5B9E\u73B0\u9009\u9879\u7EA7\u8054\u7684\u6548\u679C\u3002\u5982\u679C\u7EA7\u8054\u5C42\u7EA7\u8F83\u591A\uFF0C\u63A8\u8350\u4F7F\u7528 Cascader \u7EA7\u8054\u9009\u9879\u7EC4\u4EF6\u3002
<van-picker title="\u6807\u9898" :columns="columns" />\n
\nexport default {\n setup() {\n const columns = [\n {\n text: '\u6D59\u6C5F',\n value: 'Zhejiang',\n children: [\n {\n text: '\u676D\u5DDE',\n value: 'Hangzhou',\n children: [\n { text: '\u897F\u6E56\u533A', value: 'Xihu' },\n { text: '\u4F59\u676D\u533A', value: 'Yuhang' },\n ],\n },\n {\n text: '\u6E29\u5DDE',\n value: 'Wenzhou',\n children: [\n { text: '\u9E7F\u57CE\u533A', value: 'Lucheng' },\n { text: '\u74EF\u6D77\u533A', value: 'Ouhai' },\n ],\n },\n ],\n },\n {\n text: '\u798F\u5EFA',\n value: 'Fujian',\n children: [\n {\n text: '\u798F\u5DDE',\n value: 'Fuzhou',\n children: [\n { text: '\u9F13\u697C\u533A', value: 'Gulou' },\n { text: '\u53F0\u6C5F\u533A', value: 'Taijiang' },\n ],\n },\n {\n text: '\u53A6\u95E8',\n value: 'Xiamen',\n children: [\n { text: '\u601D\u660E\u533A', value: 'Siming' },\n { text: '\u6D77\u6CA7\u533A', value: 'Haicang' },\n ],\n },\n ],\n },\n ];\n\n return { columns };\n },\n};\n
\n\n\n\u7EA7\u8054\u9009\u62E9\u7684\u6570\u636E\u5D4C\u5957\u6DF1\u5EA6\u9700\u8981\u4FDD\u6301\u4E00\u81F4\uFF0C\u5982\u679C\u90E8\u5206\u9009\u9879\u6CA1\u6709\u5B50\u9009\u9879\uFF0C\u53EF\u4EE5\u4F7F\u7528\u7A7A\u5B57\u7B26\u4E32\u8FDB\u884C\u5360\u4F4D\u3002
\n
\u9009\u9879\u53EF\u4EE5\u4E3A\u5BF9\u8C61\u7ED3\u6784\uFF0C\u901A\u8FC7\u8BBE\u7F6E disabled
\u6765\u7981\u7528\u8BE5\u9009\u9879\u3002
<van-picker :columns="columns" />\n
\nexport default {\n setup() {\n const columns = [\n { text: '\u676D\u5DDE', value: 'Hangzhou', disabled: true },\n { text: '\u5B81\u6CE2', value: 'Ningbo' },\n { text: '\u6E29\u5DDE', value: 'Wenzhou' },\n ];\n return { columns };\n },\n};\n
\n\u82E5\u9009\u62E9\u5668\u6570\u636E\u662F\u5F02\u6B65\u83B7\u53D6\u7684\uFF0C\u53EF\u4EE5\u901A\u8FC7 loading
\u5C5E\u6027\u663E\u793A\u52A0\u8F7D\u63D0\u793A\u3002
<van-picker :columns="columns" :loading="loading" />\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const columns = ref([]);\n const loading = ref(true);\n\n setTimeout(() => {\n columns.value = [{ text: '\u9009\u9879', value: 'option' }];\n loading.value = false;\n }, 1000);\n\n return { columns, loading };\n },\n};\n
\n<van-picker\n :title="\u6807\u9898"\n :columns="columns"\n :columns-field-names="customFieldName"\n/>\n
\nexport default {\n setup() {\n const columns = [\n {\n cityName: '\u6D59\u6C5F',\n cities: [\n {\n cityName: '\u676D\u5DDE',\n cities: [{ cityName: '\u897F\u6E56\u533A' }, { cityName: '\u4F59\u676D\u533A' }],\n },\n {\n cityName: '\u6E29\u5DDE',\n cities: [{ cityName: '\u9E7F\u57CE\u533A' }, { cityName: '\u74EF\u6D77\u533A' }],\n },\n ],\n },\n {\n cityName: '\u798F\u5EFA',\n cities: [\n {\n cityName: '\u798F\u5DDE',\n cities: [{ cityName: '\u9F13\u697C\u533A' }, { cityName: '\u53F0\u6C5F\u533A' }],\n },\n {\n cityName: '\u53A6\u95E8',\n cities: [{ cityName: '\u601D\u660E\u533A' }, { cityName: '\u6D77\u6CA7\u533A' }],\n },\n ],\n },\n ];\n\n const customFieldName = {\n text: 'cityName',\n value: 'cityName',\n children: 'cities',\n };\n\n return {\n columns,\n customFieldName,\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\u9879\u5BF9\u5E94\u7684\u503C | \nnumber[] | string[] | \n- | \n
columns | \n\u5BF9\u8C61\u6570\u7EC4\uFF0C\u914D\u7F6E\u6BCF\u4E00\u5217\u663E\u793A\u7684\u6570\u636E | \nPickerOption[] | PickerOption[][] | \n[] | \n
columns-field-names | \n\u81EA\u5B9A\u4E49 columns \u7ED3\u6784\u4E2D\u7684\u5B57\u6BB5 | \nobject | \n{ text: \'text\', value: \'value\', children: \'children\' } | \n
title | \n\u9876\u90E8\u680F\u6807\u9898 | \nstring | \n- | \n
confirm-button-text | \n\u786E\u8BA4\u6309\u94AE\u6587\u5B57\uFF0C\u8BBE\u7F6E\u4E3A\u7A7A\u5B57\u7B26\u4E32\u53EF\u4EE5\u9690\u85CF\u6309\u94AE | \nstring | \n\u786E\u8BA4 | \n
cancel-button-text | \n\u53D6\u6D88\u6309\u94AE\u6587\u5B57\uFF0C\u8BBE\u7F6E\u4E3A\u7A7A\u5B57\u7B26\u4E32\u53EF\u4EE5\u9690\u85CF\u6309\u94AE | \nstring | \n\u53D6\u6D88 | \n
toolbar-position | \n\u9876\u90E8\u680F\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A bottom | \nstring | \ntop | \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
show-toolbar | \n\u662F\u5426\u663E\u793A\u9876\u90E8\u680F | \nboolean | \ntrue | \n
allow-html | \n\u662F\u5426\u5141\u8BB8\u9009\u9879\u5185\u5BB9\u4E2D\u6E32\u67D3 HTML | \nboolean | \nfalse | \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\u4E2D\u7684\u9009\u9879\u6539\u53D8\u65F6\u89E6\u53D1 | \n{ selectedValues, selectedOptions, selectedIndexes, columnIndex } | \n
click-option | \n\u70B9\u51FB\u9009\u9879\u65F6\u89E6\u53D1 | \n{ currentOption, selectedValues, selectedOptions, selectedIndexes, columnIndex } | \n
scroll-into v4.2.1 | \n\u5F53\u7528\u6237\u901A\u8FC7\u70B9\u51FB\u6216\u62D6\u62FD\u8BA9\u4E00\u4E2A\u9009\u9879\u6EDA\u52A8\u5230\u4E2D\u95F4\u7684\u9009\u62E9\u533A\u57DF\u65F6\u89E6\u53D1 | \n{ currentOption, 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
\u952E\u540D | \n\u8BF4\u660E | \n\u7C7B\u578B | \n
---|---|---|
text | \n\u9009\u9879\u6587\u5B57\u5185\u5BB9 | \nstring | number | \n
value | \n\u9009\u9879\u5BF9\u5E94\u7684\u503C | \nstring | number | \n
disabled | \n\u662F\u5426\u7981\u7528\u9009\u9879 | \nboolean | \n
children | \n\u7EA7\u8054\u9009\u9879 | \nPickerOption[] | \n
className | \n\u9009\u9879\u989D\u5916\u7C7B\u540D | \nstring | Array | object | \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
getSelectedOptions | \n\u83B7\u53D6\u5F53\u524D\u9009\u4E2D\u7684\u9009\u9879 | \n- | \n(PickerOption | undefined)[] | \n
\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A
\nimport type {\n PickerProps,\n PickerColumn,\n PickerOption,\n PickerInstance,\n PickerFieldNames,\n PickerToolbarPosition,\n PickerCancelEventParams,\n PickerChangeEventParams,\n PickerConfirmEventParams,\n} from 'vant';\n
\nPickerInstance
\u662F\u7EC4\u4EF6\u5B9E\u4F8B\u7684\u7C7B\u578B\uFF0C\u7528\u6CD5\u5982\u4E0B\uFF1A
import { ref } from 'vue';\nimport type { PickerInstance } from 'vant';\n\nconst pickerRef = ref<PickerInstance>();\n\npickerRef.value?.confirm();\n
\n\u7EC4\u4EF6\u63D0\u4F9B\u4E86\u4E0B\u5217 CSS \u53D8\u91CF\uFF0C\u53EF\u7528\u4E8E\u81EA\u5B9A\u4E49\u6837\u5F0F\uFF0C\u4F7F\u7528\u65B9\u6CD5\u8BF7\u53C2\u8003 ConfigProvider \u7EC4\u4EF6\u3002
\n\u540D\u79F0 | \n\u9ED8\u8BA4\u503C | \n\u63CF\u8FF0 | \n
---|---|---|
--van-picker-background | \nvar(--van-background-2) | \n- | \n
--van-picker-toolbar-height | \n44px | \n- | \n
--van-picker-title-font-size | \nvar(--van-font-size-lg) | \n- | \n
--van-picker-title-line-height | \nvar(--van-line-height-md) | \n- | \n
--van-picker-action-padding | \n0 var(--van-padding-md) | \n- | \n
--van-picker-action-font-size | \nvar(--van-font-size-md) | \n- | \n
--van-picker-confirm-action-color | \nvar(--van-primary-color) | \n- | \n
--van-picker-cancel-action-color | \nvar(--van-text-color-2) | \n- | \n
--van-picker-option-padding | \n0 var(--van-padding-base) | \n- | \n
--van-picker-option-font-size | \nvar(--van-font-size-lg) | \n- | \n
--van-picker-option-text-color | \nvar(--van-text-color) | \n- | \n
--van-picker-option-disabled-opacity | \n0.3 | \n- | \n
--van-picker-mask-color | \nlinear-gradient | \n- | \n
--van-picker-loading-icon-color | \nvar(--van-primary-color) | \n- | \n
--van-picker-loading-mask-color | \nrgba(255, 255, 255, 0.9) | \n- | \n
\u53C2\u89C1\u684C\u9762\u7AEF\u9002\u914D\u3002
\n