[Improvement] Radio: add label-position prop (#1446)

This commit is contained in:
neverland 2018-07-09 21:27:13 +08:00 committed by GitHub
parent b5b25ac923
commit 8c7dc1e622
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 2 deletions

View File

@ -61,6 +61,7 @@ export default {
| name | Radio name | `any` | - | | name | Radio name | `any` | - |
| disabled | Whether to disable radio | `Boolean` | `false` | | disabled | Whether to disable radio | `Boolean` | `false` |
| label-disabled | Whether to disable label click | `Boolean` | `false` | | label-disabled | Whether to disable label click | `Boolean` | `false` |
| label-position | Can be set to `left` | `String` | `right` |
### RadioGroup API ### RadioGroup API

View File

@ -10,7 +10,7 @@
> >
<icon :name="currentValue === name ? 'checked' : 'check'" /> <icon :name="currentValue === name ? 'checked' : 'check'" />
</span> </span>
<span v-if="$slots.default" :class="b('label')" @click="onClickLabel"> <span v-if="$slots.default" :class="b('label', labelPosition)" @click="onClickLabel">
<slot /> <slot />
</span> </span>
</div> </div>
@ -29,7 +29,8 @@ export default create({
name: null, name: null,
value: null, value: null,
disabled: Boolean, disabled: Boolean,
labelDisabled: Boolean labelDisabled: Boolean,
labelPosition: Boolean
}, },
computed: { computed: {

View File

@ -63,6 +63,7 @@ export default {
| name | 标识 Radio 名称 | 任意类型 | - | | name | 标识 Radio 名称 | 任意类型 | - |
| disabled | 是否为禁用状态 | `Boolean` | `false` | | disabled | 是否为禁用状态 | `Boolean` | `false` |
| label-disabled | 是否禁用文本内容点击 | `Boolean` | `false` | | label-disabled | 是否禁用文本内容点击 | `Boolean` | `false` |
| label-position | 文本位置,可选值为 `left` | `String` | `right` |
### RadioGroup API ### RadioGroup API

View File

@ -30,9 +30,15 @@ $van-radio-size: 20px;
&__label { &__label {
line-height: $van-radio-size; line-height: $van-radio-size;
margin-left: 10px; margin-left: 10px;
&--left {
float: left;
margin: 0 10px 0 0;
}
} }
.van-icon { .van-icon {
width: 1em;
pointer-events: none; pointer-events: none;
font-size: $van-radio-size; font-size: $van-radio-size;
} }