vant/src/address-list
2020-11-25 22:39:06 +08:00
..
2020-10-22 16:44:19 +08:00
2020-11-25 22:39:06 +08:00
2020-08-24 10:37:52 +08:00
2020-08-24 10:37:52 +08:00
2020-11-22 16:06:24 +08:00
2020-11-22 16:06:24 +08:00

AddressList

Install

import { createApp } from 'vue';
import { AddressList } from 'vant';

const app = createApp();
app.use(AddressList);

Usage

Basic Usage

<van-address-list
  v-model="chosenAddressId"
  :list="list"
  :disabled-list="disabledList"
  disabled-text="The following address is out of range"
  default-tag-text="Default"
  @add="onAdd"
  @edit="onEdit"
/>
import { Toast } from 'vant';

export default {
  data() {
    return {
      chosenAddressId: '1',
      list: [
        {
          id: '1',
          name: 'John Snow',
          tel: '13000000000',
          address: 'Somewhere',
          isDefault: true,
        },
        {
          id: '2',
          name: 'Ned Stark',
          tel: '1310000000',
          address: 'Somewhere',
        },
      ],
      disabledList: [
        {
          id: '3',
          name: 'Tywin',
          tel: '1320000000',
          address: 'Somewhere',
        },
      ],
    };
  },
  methods: {
    onAdd() {
      Toast('Add');
    },
    onEdit(item, index) {
      Toast('Edit:' + index);
    },
  },
};

API

Props

Attribute Description Type Default
v-model Id of chosen address string -
list Address list Address[] []
disabled-list Disabled address list Address[] []
disabled-text Disabled text string -
switchable Whether to allow switch address boolean true
add-button-text Add button text string Add new address
default-tag-text v2.3.0 Default tag text string -

Events

Event Description Arguments
add Emitted when the add button is clicked -
edit Emitted when the edit icon of address is clicked item: address objectindex
select Emitted when an address is selected item: address objectindex
edit-disabled Emitted when the edit icon of disabled address is clicked item: address objectindex
select-disabled Emitted when a disabled address is selected item: address objectindex
click-item Emitted when an address item is clicked item: address objectindex

Data Structure of Address

Key Description Type
id Id number | string
name Name string
tel Phone number | string
address Address string
isDefault Is default address boolean

Slots

Name Description SlotProps
default Custom content after list -
top Custom content before list -
item-bottom v2.5.0 Custom content after list item item

Less Variables

How to use: Custom Theme.

Name Default Value Description
@address-list-padding @padding-sm @padding-sm 80px -
@address-list-disabled-text-color @gray-6 -
@address-list-disabled-text-padding @padding-base * 5 0 @padding-md -
@address-list-disabled-text-font-size @font-size-md -
@address-list-disabled-text-line-height @line-height-md -
@address-list-add-button-z-index 999 -
@address-list-item-padding @padding-sm -
@address-list-item-text-color @text-color -
@address-list-item-disabled-text-color @gray-5 -
@address-list-item-font-size 13px -
@address-list-item-line-height @line-height-sm -
@address-list-item-radio-icon-color @red -
@address-list-edit-icon-size 20px -