/*! For license information please see 6163.6fb5b019.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["6163"],{50191:function(n,s,a){"use strict";a.r(s);var t=a("80681");let e=["innerHTML"];s.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'

Area \u7701\u5E02\u533A\u9009\u62E9

\n

\u4ECB\u7ECD

\n

\u7701\u5E02\u533A\u4E09\u7EA7\u8054\u52A8\u9009\u62E9\uFF0C\u901A\u5E38\u4E0E\u5F39\u51FA\u5C42\u7EC4\u4EF6\u914D\u5408\u4F7F\u7528\u3002

\n

\u5F15\u5165

\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

\n
import { createApp } from 'vue';\nimport { Area } from 'vant';\n\nconst app = createApp();\napp.use(Area);\n
\n

\u4EE3\u7801\u6F14\u793A

\n

\u57FA\u7840\u7528\u6CD5

\n

\u521D\u59CB\u5316\u7701\u5E02\u533A\u7EC4\u4EF6\u65F6\uFF0C\u9700\u8981\u901A\u8FC7 area-list \u5C5E\u6027\u4F20\u5165\u7701\u5E02\u533A\u6570\u636E\u3002

\n
<van-area title="\u6807\u9898" :area-list="areaList" />\n
\n

areaList \u683C\u5F0F

\n

areaList \u4E3A\u5BF9\u8C61\u7ED3\u6784\uFF0C\u5305\u542B province_list\u3001city_list\u3001county_list \u4E09\u4E2A key\u3002

\n

\u6BCF\u9879\u4EE5\u5730\u533A\u7801\u4F5C\u4E3A key\uFF0C\u7701\u5E02\u533A\u540D\u5B57\u4F5C\u4E3A value\u3002\u5730\u533A\u7801\u4E3A 6 \u4F4D\u6570\u5B57\uFF0C\u524D\u4E24\u4F4D\u4EE3\u8868\u7701\u4EFD\uFF0C\u4E2D\u95F4\u4E24\u4F4D\u4EE3\u8868\u57CE\u5E02\uFF0C\u540E\u4E24\u4F4D\u4EE3\u8868\u533A\u53BF\uFF0C\u4EE5 0 \u8865\u8DB3 6 \u4F4D\u3002\u6BD4\u5982\u5317\u4EAC\u7684\u5730\u533A\u7801\u4E3A 11\uFF0C\u4EE5 0 \u8865\u8DB3 6 \u4F4D\uFF0C\u4E3A 110000\u3002

\n

\u793A\u4F8B\u6570\u636E\u5982\u4E0B\uFF1A

\n
const areaList = {\n  province_list: {\n    110000: '\u5317\u4EAC\u5E02',\n    120000: '\u5929\u6D25\u5E02',\n  },\n  city_list: {\n    110100: '\u5317\u4EAC\u5E02',\n    120100: '\u5929\u6D25\u5E02',\n  },\n  county_list: {\n    110101: '\u4E1C\u57CE\u533A',\n    110102: '\u897F\u57CE\u533A',\n    // ....\n  },\n};\n
\n

\u4E2D\u56FD\u7701\u5E02\u533A\u6570\u636E

\n

Vant \u63D0\u4F9B\u4E86\u4E00\u4EFD\u4E2D\u56FD\u7701\u5E02\u533A\u6570\u636E\uFF0C\u4F60\u53EF\u4EE5\u5B89\u88C5 @vant/area-data npm \u5305\u6765\u5F15\u5165\uFF1A

\n
# \u901A\u8FC7 npm\nnpm i @vant/area-data\n\n# \u901A\u8FC7 yarn\nyarn add @vant/area-data\n\n# \u901A\u8FC7 pnpm\npnpm add @vant/area-data\n\n# \u901A\u8FC7 Bun\nbun add @vant/area-data\n
\n
import { areaList } from '@vant/area-data';\n\nexport default {\n  setup() {\n    return { areaList };\n  },\n};\n
\n
\n

Tips: \u4E2D\u56FD\u7684\u884C\u653F\u533A\u5212\u6BCF\u5E74\u90FD\u4F1A\u6709\u53D8\u52A8\uFF0C\u5982\u679C\u53D1\u73B0\u7701\u5E02\u533A\u6570\u636E\u672A\u53CA\u65F6\u66F4\u65B0\uFF0C\u6B22\u8FCE\u63D0 Pull Request \u5E2E\u52A9\u6211\u4EEC\u66F4\u65B0\u3002\u4F60\u53EF\u4EE5\u5728\u300C\u56FD\u5BB6\u7EDF\u8BA1\u5C40 - \u5168\u56FD\u533A\u5212\u4EE3\u7801\u300D \u548C\u300C\u6C11\u653F\u90E8 - \u884C\u653F\u533A\u5212\u4EE3\u7801\u300D\u4E0A\u67E5\u8BE2\u5230\u6700\u65B0\u6570\u636E\uFF0C\u8BF7\u6839\u636E\u5B98\u65B9\u6570\u636E\u8FDB\u884C\u6838\u5B9E\u3002

\n
\n

\u63A7\u5236\u9009\u4E2D\u9879

\n

\u901A\u8FC7 v-model \u7ED1\u5B9A\u5F53\u524D\u9009\u4E2D\u7684\u5730\u533A\u7801\u3002

\n
<van-area v-model="value" title="\u6807\u9898" :area-list="areaList" />\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const value = ref('330302');\n    return { value };\n  },\n};\n
\n

\u914D\u7F6E\u663E\u793A\u5217

\n

\u53EF\u4EE5\u901A\u8FC7 columns-num \u5C5E\u6027\u914D\u7F6E\u7701\u5E02\u533A\u663E\u793A\u7684\u5217\u6570\uFF0C\u9ED8\u8BA4\u60C5\u51B5\u4E0B\u4F1A\u663E\u793A\u7701\u5E02\u533A\uFF0C\u5F53\u4F60\u8BBE\u7F6E\u4E3A 2\uFF0C\u5219\u53EA\u4F1A\u663E\u793A\u7701\u5E02\u9009\u62E9\u3002

\n
<van-area title="\u6807\u9898" :area-list="areaList" :columns-num="2" />\n
\n

\u914D\u7F6E\u5217\u5360\u4F4D\u63D0\u793A\u6587\u5B57

\n

\u53EF\u4EE5\u901A\u8FC7 columns-placeholder \u5C5E\u6027\u914D\u7F6E\u6BCF\u4E00\u5217\u7684\u5360\u4F4D\u63D0\u793A\u6587\u5B57\u3002

\n
<van-area\n  title="\u6807\u9898"\n  :area-list="areaList"\n  :columns-placeholder="['\u8BF7\u9009\u62E9', '\u8BF7\u9009\u62E9', '\u8BF7\u9009\u62E9']"\n/>\n
\n

API

\n

Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53C2\u6570\u8BF4\u660E\u7C7B\u578B\u9ED8\u8BA4\u503C
v-model\u5F53\u524D\u9009\u4E2D\u9879\u5BF9\u5E94\u7684\u5730\u533A\u7801string-
title\u9876\u90E8\u680F\u6807\u9898string-
confirm-button-text\u786E\u8BA4\u6309\u94AE\u6587\u5B57string\u786E\u8BA4
cancel-button-text\u53D6\u6D88\u6309\u94AE\u6587\u5B57string\u53D6\u6D88
area-list\u7701\u5E02\u533A\u6570\u636E\uFF0C\u683C\u5F0F\u89C1\u4E0B\u65B9object-
columns-placeholder\u5217\u5360\u4F4D\u63D0\u793A\u6587\u5B57string[][]
loading\u662F\u5426\u663E\u793A\u52A0\u8F7D\u72B6\u6001booleanfalse
readonly\u662F\u5426\u4E3A\u53EA\u8BFB\u72B6\u6001\uFF0C\u53EA\u8BFB\u72B6\u6001\u4E0B\u65E0\u6CD5\u5207\u6362\u9009\u9879booleanfalse
option-height\u9009\u9879\u9AD8\u5EA6\uFF0C\u652F\u6301 px vw vh rem \u5355\u4F4D\uFF0C\u9ED8\u8BA4 pxnumber | string44
columns-num\u663E\u793A\u5217\u6570\uFF0C3-\u7701\u5E02\u533A\uFF0C2-\u7701\u5E02\uFF0C1-\u7701number | string3
visible-option-num\u53EF\u89C1\u7684\u9009\u9879\u4E2A\u6570number | string6
swipe-duration\u5FEB\u901F\u6ED1\u52A8\u65F6\u60EF\u6027\u6EDA\u52A8\u7684\u65F6\u957F\uFF0C\u5355\u4F4D msnumber | string1000
\n

Events

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u4E8B\u4EF6\u540D\u8BF4\u660E\u56DE\u8C03\u53C2\u6570
confirm\u70B9\u51FB\u5B8C\u6210\u6309\u94AE\u65F6\u89E6\u53D1{ selectedValues, selectedOptions, selectedIndexes }
cancel\u70B9\u51FB\u53D6\u6D88\u6309\u94AE\u65F6\u89E6\u53D1{ selectedValues, selectedOptions, selectedIndexes }
change\u9009\u9879\u6539\u53D8\u65F6\u89E6\u53D1{ selectedValues, selectedOptions, selectedIndexes, columnIndex }
\n

Slots

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u8BF4\u660E\u53C2\u6570
toolbar\u81EA\u5B9A\u4E49\u6574\u4E2A\u9876\u90E8\u680F\u7684\u5185\u5BB9-
title\u81EA\u5B9A\u4E49\u6807\u9898\u5185\u5BB9-
confirm\u81EA\u5B9A\u4E49\u786E\u8BA4\u6309\u94AE\u5185\u5BB9-
cancel\u81EA\u5B9A\u4E49\u53D6\u6D88\u6309\u94AE\u5185\u5BB9-
columns-top\u81EA\u5B9A\u4E49\u9009\u9879\u4E0A\u65B9\u5185\u5BB9-
columns-bottom\u81EA\u5B9A\u4E49\u9009\u9879\u4E0B\u65B9\u5185\u5BB9-
\n

\u65B9\u6CD5

\n

\u901A\u8FC7 ref \u53EF\u4EE5\u83B7\u53D6\u5230 Area \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\uFF0C\u8BE6\u89C1\u7EC4\u4EF6\u5B9E\u4F8B\u65B9\u6CD5\u3002

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u65B9\u6CD5\u540D\u8BF4\u660E\u53C2\u6570\u8FD4\u56DE\u503C
confirm\u505C\u6B62\u60EF\u6027\u6EDA\u52A8\u5E76\u89E6\u53D1 confirm \u4E8B\u4EF6--
getSelectedOptions\u83B7\u53D6\u5F53\u524D\u9009\u4E2D\u7684\u9009\u9879-PickerOption[]
\n

\u7C7B\u578B\u5B9A\u4E49

\n

\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A

\n
import type { AreaProps, AreaList, AreaInstance } from 'vant';\n
\n

AreaInstance \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u7684\u7C7B\u578B\uFF0C\u7528\u6CD5\u5982\u4E0B\uFF1A

\n
import { ref } from 'vue';\nimport type { AreaInstance } from 'vant';\n\nconst areaRef = ref<AreaInstance>();\n\nareaRef.value?.confirm();\n
\n

\u5E38\u89C1\u95EE\u9898

\n

\u5728\u684C\u9762\u7AEF\u65E0\u6CD5\u64CD\u4F5C\u7EC4\u4EF6\uFF1F

\n

\u53C2\u89C1\u684C\u9762\u7AEF\u9002\u914D\u3002

\n
'},null,8,e))}}}]);