[Improvement] AddressList: upgrade style, add slot (#1628)

This commit is contained in:
neverland
2018-08-14 15:04:21 +08:00
committed by GitHub
parent 513b62053e
commit 225bdaef01
8 changed files with 46 additions and 38 deletions

View File

@@ -35,8 +35,8 @@ export default {
address: '浙江省杭州市滨江区江南大道 15 号'
}
],
add: '新增收货地址',
edit: '编辑收货地址'
add: '新增地址',
edit: '编辑地址'
},
'en-US': {
list: [

View File

@@ -77,3 +77,10 @@ export default {
| name | Name | `String` |
| tel | Phone | `String` |
| address | Address | `String` |
### Slot
| 名称 | 说明 |
|-----------|-----------|
| - | Custom content after list |
| top | Custom content before list |

View File

@@ -1,5 +1,6 @@
<template>
<div :class="b()">
<slot name="top" />
<radio-group :value="value" :class="b('group')" @input="$emit('input', $event)">
<cell-group>
<cell v-for="(item, index) in list" :key="item.id" is-link>
@@ -16,12 +17,13 @@
</cell>
</cell-group>
</radio-group>
<cell
icon="add"
is-link
<slot />
<van-button
square
size="large"
type="danger"
:class="b('add')"
class="van-hairline--top"
:title="addButtonText || $t('add')"
:text="addButtonText || $t('add')"
@click="$emit('add')"
/>
</div>
@@ -31,13 +33,15 @@
import create from '../utils/create';
import Radio from '../radio';
import RadioGroup from '../radio-group';
import VanButton from '../button';
export default create({
name: 'address-list',
components: {
Radio,
RadioGroup
RadioGroup,
VanButton
},
props: {

View File

@@ -38,18 +38,8 @@ exports[`renders demo correctly 1`] = `
</div>
</div>
</div>
<div class="van-hairline--top van-cell van-cell--clickable van-hairline van-address-list__add">
<i class="van-icon van-icon-add van-cell__left-icon" style="color:undefined;size:undefined;">
<!---->
</i>
<div class="van-cell__title"><span>新增收货地址</span>
<!---->
</div>
<!---->
<i class="van-icon van-icon-arrow van-cell__right-icon" style="color:undefined;size:undefined;">
<!---->
</i>
</div>
<button class="van-button van-button--danger van-button--large van-button--square van-address-list__add">
<!----><span class="van-button__text">新增地址</span></button>
</div>
</div>
</div>

View File

@@ -44,10 +44,10 @@ export default {
methods: {
onAdd() {
Toast('新增收货地址');
Toast('新增地址');
},
onEdit(item, index) {
Toast('编辑收货地址:' + index);
Toast('编辑地址:' + index);
}
}
}
@@ -60,7 +60,7 @@ export default {
|-----------|-----------|-----------|-------------|
| v-model | 当前选中地址的 id | String | - |
| list | 地址列表 | Array | `[]` |
| add-button-text | 底部按钮文字 | String | `新增收货地址` |
| add-button-text | 底部按钮文字 | String | `新增地址` |
### Event
@@ -71,6 +71,7 @@ export default {
| select | 切换选中的地址时触发 | item: 当前地址对象index: 索引 |
### 数据格式
#### 地址列表字段说明
| key | 说明 | 类型 |
|-----------|-----------|-----------|
@@ -78,3 +79,10 @@ export default {
| name | 收货人姓名 | `String` |
| tel | 收货人手机号 | `String` |
| address | 收货地址 | `String` |
### Slot
| 名称 | 说明 |
|-----------|-----------|
| - | 在列表下方插入内容 |
| top | 在顶部插入内容 |