vant/docs/markdown/en-US/address-list.md
2017-12-14 17:36:55 +08:00

80 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## AddressList
### Install
``` javascript
import { AddressList } from 'vant';
Vue.use(AddressList);
```
### Usage
#### Basic Usage
```html
<van-address-list
v-model="chosenAddressId"
:list="list"
@add="onAdd"
@edit="onEdit"
/>
```
```javascript
export default {
data() {
return {
chosenAddressId: '1',
list: [
{
id: '1',
name: 'John Snow',
tel: '13000000000',
address: 'Somewhere'
},
{
id: '2',
name: 'Ned Stark',
tel: '1310000000',
address: 'Somewhere'
}
]
}
},
methods: {
onAdd() {
Toast('Add');
},
onEdit(item, index) {
Toast('Edit:' + index);
}
}
}
```
### API
| Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------|
| v-model | Id of chosen address | String | - | - |
| list | Address list | Array | `[]` | - |
| addButtonText | Add button text | String | `Add new address` | - |
### Event
| Event | Description | Attribute |
|-----------|-----------|-----------|
| add | Triggered when click add button | - |
| edit | Triggered when click edit button | item: address objectindex |
| select | Triggered when select address | item: address objectindex |
### Address Data Structure
| key | Description | Type |
|-----------|-----------|-----------|
| id | Id | `String | Number` |
| name | Name | `String` |
| tel | Phone | `String` |
| address | Address | `String` |