-
+
Checkbox
Checkbox
diff --git a/examples/index.js b/examples/index.js
index e9a228266..2aeae2b72 100644
--- a/examples/index.js
+++ b/examples/index.js
@@ -1,12 +1,14 @@
import Vue from 'vue'
import Checkbox from './checkbox.vue'
import Button from './button.vue'
+import Radio from './radio.vue'
// import Dialog from './dialog.vue'
import './index.less'
new Vue({
el: '#app',
template: `
@@ -15,5 +17,6 @@ new Vue({
AntButton: Button,
// AntDialog: Dialog,
Checkbox,
+ Radio,
},
})
diff --git a/examples/radio.vue b/examples/radio.vue
new file mode 100644
index 000000000..b9c7c8f2e
--- /dev/null
+++ b/examples/radio.vue
@@ -0,0 +1,52 @@
+
+
+
Radio
+
Radio
+
+
+
+ {{showMore ? "删除": "添加"}}
+
+ Radio1
+ Radio2
+ Radio3
+ Radio4
+
+
+
+
+
From 5d639b034c594e346b9da064437f1ade98747e9c Mon Sep 17 00:00:00 2001
From: tangjinzhou <415800467@qq.com>
Date: Fri, 27 Oct 2017 14:56:23 +0800
Subject: [PATCH 05/47] radio
---
.babelrc | 2 +-
components/checkbox/Group.vue | 4 +--
components/checkbox/checkbox.vue | 4 ---
components/radio/Group.vue | 4 +--
components/radio/Radio.vue | 1 -
components/radio/RadioButton.vue | 41 +++++++++++++++++++++++++++++++
components/radio/index.js | 10 ++++++++
components/radio/style/index.less | 1 +
examples/radio.vue | 10 ++++++++
package.json | 1 +
10 files changed, 68 insertions(+), 10 deletions(-)
diff --git a/.babelrc b/.babelrc
index 3bde2e0da..4a10099cb 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,4 +1,4 @@
{
"presets": ["env"],
- "plugins": ["transform-vue-jsx"]
+ "plugins": ["transform-vue-jsx", "transform-object-rest-spread"]
}
diff --git a/components/checkbox/Group.vue b/components/checkbox/Group.vue
index 8d1ddf51c..23999dc52 100644
--- a/components/checkbox/Group.vue
+++ b/components/checkbox/Group.vue
@@ -56,8 +56,8 @@ export default {
const { options, $slots, checkedStatus } = this
if (options.length === 0 && $slots.default) {
children.forEach(({ componentOptions = {}, children: newChildren }) => {
- const { tag, propsData } = componentOptions
- if (tag === 'Checkbox') {
+ const { Ctor, propsData } = componentOptions
+ if (Ctor && Ctor.options.name === 'Checkbox') {
propsData.isGroup = true
propsData.onGroupChange = this.handleChange
propsData.checked = checkedStatus.has(propsData.value)
diff --git a/components/checkbox/checkbox.vue b/components/checkbox/checkbox.vue
index 39c58b04b..26caa0fa4 100644
--- a/components/checkbox/checkbox.vue
+++ b/components/checkbox/checkbox.vue
@@ -28,10 +28,6 @@ export default {
indeterminate: Boolean,
onGroupChange: Function,
},
- data () {
- return {
- }
- },
model: {
prop: 'checked',
},
diff --git a/components/radio/Group.vue b/components/radio/Group.vue
index 070dcc6c7..d8bf0cf88 100644
--- a/components/radio/Group.vue
+++ b/components/radio/Group.vue
@@ -54,8 +54,8 @@ export default {
const { options, $slots, value } = this
if (options.length === 0 && $slots.default) {
children.forEach(({ componentOptions = {}, children: newChildren }) => {
- const { tag, propsData } = componentOptions
- if (tag === 'Radio') {
+ const { Ctor, propsData } = componentOptions
+ if (Ctor && Ctor.options.name === 'Radio') {
propsData.isGroup = true
propsData.onGroupChange = this.handleChange
propsData.checked = propsData.value === value
diff --git a/components/radio/Radio.vue b/components/radio/Radio.vue
index cfc568780..c316ba495 100644
--- a/components/radio/Radio.vue
+++ b/components/radio/Radio.vue
@@ -25,7 +25,6 @@ export default {
isGroup: Boolean,
value: [String, Number, Boolean],
name: String,
- indeterminate: Boolean,
onGroupChange: Function,
},
model: {
diff --git a/components/radio/RadioButton.vue b/components/radio/RadioButton.vue
index e69de29bb..66924c6b4 100644
--- a/components/radio/RadioButton.vue
+++ b/components/radio/RadioButton.vue
@@ -0,0 +1,41 @@
+
+
+ {{item.label}}
+
+
+
+
diff --git a/components/radio/index.js b/components/radio/index.js
index 56c40cc32..a26584b0e 100644
--- a/components/radio/index.js
+++ b/components/radio/index.js
@@ -2,5 +2,15 @@ import Radio from './Radio.vue'
import RadioGroup from './Group.vue'
Radio.Group = RadioGroup
+Radio.Button = {
+ extends: Radio,
+ props: {
+ ...Radio.props,
+ prefixCls: {
+ default: 'ant-radio-button',
+ type: String,
+ },
+ },
+}
export default Radio
diff --git a/components/radio/style/index.less b/components/radio/style/index.less
index 7d9c4b06e..d573a96d7 100644
--- a/components/radio/style/index.less
+++ b/components/radio/style/index.less
@@ -134,6 +134,7 @@ span.@{radio-prefix-cls} + * {
}
.@{radio-prefix-cls}-button-wrapper {
+ float: left;
margin: 0;
height: @input-height-base;
line-height: @input-height-base - 2px;
diff --git a/examples/radio.vue b/examples/radio.vue
index b9c7c8f2e..3092e54c9 100644
--- a/examples/radio.vue
+++ b/examples/radio.vue
@@ -13,6 +13,14 @@
Radio4
+
+
+ Hangzhou
+ Shanghai
+ Beijing
+ Chengdu
+
+