Skip to content

AddressPicker Address Picker Component

This picker is used for selecting addresses

Tip

This project references the component development approach of the uView-Plus open-source project, implementing custom components based on Vue 3 and TypeScript.
Thanks to the uView-Plus open-source project and its team members for their contributions; their component development approach has provided valuable reference for this project. If you need to learn more about component development details.

📌Platform Differences

APP(vue)H5WeChat Mini ProgramAlipay Mini Program

🏯Basic Usage Example

html
<!-- Global usage -->
<hy-address-picker hasInput></hy-address-picker>

Open via External Button

html
<template>
    <view>
        <hy-address-picker :show="show"></hy-address-picker>
        <hy-button @click="show = true">Open</hy-button>
    </view>
</template>

<script setup>
    import { ref } from 'vue';

    const show = ref(false);
</script>

Open via Built-in Input Field

html
<template>
    <view>
        <hy-address-picker hasInput v-model="value"></hy-address-picker>
    </view>
</template>

<script setup>
    import { ref } from 'vue';

    const value = ref(Date.now());
</script>

API

AddressPicker Props

ParameterDescriptionTypeDefault
hasInputWhether to include a built-in input fieldbooleanfalse
inputCollection of input field properties; available when hasInput is true, see Input Api for detailsHyInputProps-
showControls the popup and dismissal of the pickerbooleanfalse
popupModeControls the popup direction of the pickerbottom|center|left|right|topbottom
showToolbarWhether to show the top toolbarbooleantrue
v-modelBinding valuestring-
titleTop titlestring-
separatorCondition for splitting the string into an arraystring" "
loadingWhether to show the loading statebooleanfalse
itemHeightHeight of a single option in each columnnumber44
cancelTextText of the cancel buttonstringCancel
confirmTextText of the confirm buttonstringConfirm
cancelColorColor of the cancel buttonstring#909193
confirmColorColor of the confirm buttonstring-
visibleItemCountNumber of visible options per columnnumber5
closeOnClickOverlayWhether to allow closing the picker by clicking the overlaybooleanfalse
defaultIndexDefault index for each columnarray-
toolbarRightSlotWhether to enable the right slotbooleanfalse
customStyleCustom external style of the input fieldCSSProperties-

Events

Event NameDescriptionCallback Parameters
closeTriggered when the picker is closed-
confirmTriggered when the confirm button is clicked, returns the currently selected valueArray: see the "Callback Parameters" section above
changeTriggered when the selected value changesArray: see the "Callback Parameters" section above
cancelTriggered when the cancel button is clicked-

Slots

Slot NameDescriptionReceived Value
triggerCustom input fieldvalue
toolbar-rightToolbar right content; customizes the right-side content. Due to WeChat Mini Program limitations, you must also set :toolbarRightSlot="true" for it to take effect.-
toolbar-bottomContent below the toolbar; customizes the bottom content-

Methods

Method NameDescription
setFormatterInternal method exposed for WeChat Mini Program compatibility; see description above
03:29