From d7403a0241b90d5be5d6e308ab66363c5254cc69 Mon Sep 17 00:00:00 2001 From: ddchef Date: Mon, 26 Feb 2018 14:22:29 +0800 Subject: [PATCH] [new feature]Checkbox: support disabled label (#644) --- docs/demos/views/checkbox.vue | 9 +++++++++ docs/markdown/zh-CN/checkbox.md | 5 +++++ packages/checkbox/index.vue | 10 +++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/demos/views/checkbox.vue b/docs/demos/views/checkbox.vue index e3962cf1b..b7555f1e4 100644 --- a/docs/demos/views/checkbox.vue +++ b/docs/demos/views/checkbox.vue @@ -9,6 +9,11 @@ {{ $t('checkbox') }} 2 + + {{ $t('checkbox') }} 2 + {{ $t('checkbox') }} 2 + + 复选框 2 ``` +#### 禁用内容部分点击事件 +```html +复选框 3 +``` #### Checkbox 组 需要与`van-checkbox-group`一起使用,选中值是一个数组,通过`v-model`绑定在`van-checkbox-group`上,数组中的项即为选中的`Checkbox`的`name`属性设置的值 @@ -93,6 +97,7 @@ export default { |-----------|-----------|-----------|-------------|-------------| | name | 标识 Checkbox 名称 | `Boolean` | `false` | - | | disabled | 是否禁用单选框 | `Boolean` | `false` | - | +| label-disabled | 是否禁用单选框内容点击 | `Boolean` | `false` | - | | shape | 形状 | `String` | `round` | `square` | ### CheckboxGroup API diff --git a/packages/checkbox/index.vue b/packages/checkbox/index.vue index ba92c4cc0..54cebf158 100644 --- a/packages/checkbox/index.vue +++ b/packages/checkbox/index.vue @@ -10,7 +10,7 @@ ]" @click="onClick" /> - + @@ -28,6 +28,10 @@ export default create({ props: { value: {}, disabled: Boolean, + labelDisabled: { + type: Boolean, + default: false + }, name: [String, Number], shape: { type: String, @@ -96,8 +100,8 @@ export default create({ }, methods: { - onClick() { - if (!this.isDisabled) { + onClick(flag) { + if (!this.isDisabled && (flag !== 'label' || (flag === 'label' && !this.labelDisabled))) { this.currentValue = !this.currentValue; } }