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 ideas have provided valuable reference for this project. If you need to learn more about the component development details.

📌 Platform Differences ​

APP(vue)H5WeChat Mini ProgramAlipay Mini Program
✔✔✔✔

🏯 Basic Usage ​

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 Internal Input Box ​

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 Value
hasInputWhether to include a built-in input boxbooleanfalse
inputCollection of input box properties, available when hasInput is true, see Input API for detailsHyInputProps-
showUsed to control the pop-up and collapse of the pickerbooleanfalse
popupModeUsed to control the pop-up direction of the pickerbottom|center|left|right|topbottom
showToolbarWhether to show the top toolbarbooleantrue
v-modelBinding valuestring-
titleTop titlestring-
separatorDelimiter used to split 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 in each columnnumber5
closeOnClickOverlayWhether to allow closing the picker by clicking the overlaybooleanfalse
defaultIndexDefault index for each columnarray-
toolbarRightSlotWhether to enable the right slotbooleanfalse
customStyleCustom outer style of the input boxCSSProperties-

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
cancelClick the cancel button-

Slots ​

Slot NameDescriptionAccepted Value
triggerCustom input boxvalue
toolbar-rightToolbar right content, customizes the right-side content. Due to WeChat Mini Program limitations, you need to 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 the description above

CSS Variables ​

Variable NameDescriptionDefault Value
--hy-address-picker-radiusInput box border radius4px
--hy-address-picker-borderInput box border1px solid #eee
--hy-address-picker-paddingInput box padding0 10px
12:33
battery