mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-11-29 18:48:32 +08:00
radio
This commit is contained in:
parent
3983e6d5b8
commit
5d639b034c
2
.babelrc
2
.babelrc
@ -1,4 +1,4 @@
|
||||
{
|
||||
"presets": ["env"],
|
||||
"plugins": ["transform-vue-jsx"]
|
||||
"plugins": ["transform-vue-jsx", "transform-object-rest-spread"]
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -28,10 +28,6 @@ export default {
|
||||
indeterminate: Boolean,
|
||||
onGroupChange: Function,
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
}
|
||||
},
|
||||
model: {
|
||||
prop: 'checked',
|
||||
},
|
||||
|
@ -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
|
||||
|
@ -25,7 +25,6 @@ export default {
|
||||
isGroup: Boolean,
|
||||
value: [String, Number, Boolean],
|
||||
name: String,
|
||||
indeterminate: Boolean,
|
||||
onGroupChange: Function,
|
||||
},
|
||||
model: {
|
||||
|
@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<div :class="`${prefixCls}`">
|
||||
<Radio v-for="item in options" :key="item.value" :checked="item.value === value"
|
||||
:value="item.value" :disabled="item.disabled" @change="handleChange">{{item.label}}</Radio>
|
||||
<slot v-if="options.length === 0"></slot>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import Radio from './Radio.vue'
|
||||
export default {
|
||||
name: 'Radio',
|
||||
props: {
|
||||
prefixCls: {
|
||||
default: 'ant-radio-button',
|
||||
type: String,
|
||||
},
|
||||
value: [String, Number],
|
||||
size: {
|
||||
default: 'default',
|
||||
validator (value) {
|
||||
return ['large', 'default', 'small'].includes(value)
|
||||
},
|
||||
},
|
||||
options: {
|
||||
default: () => [],
|
||||
type: Array,
|
||||
},
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
curValue: this.value,
|
||||
}
|
||||
},
|
||||
model: {
|
||||
prop: 'value',
|
||||
},
|
||||
components: {
|
||||
Radio,
|
||||
},
|
||||
}
|
||||
</script>
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -13,6 +13,14 @@
|
||||
<Radio v-if="showMore" name="test4" value="4">Radio4</Radio>
|
||||
</RadioGroup>
|
||||
<RadioGroup :options="options" v-model="value1" @change="change"></RadioGroup>
|
||||
<div>
|
||||
<RadioGroup v-model="value2" size="large">
|
||||
<RadioButton value="a">Hangzhou</RadioButton>
|
||||
<RadioButton value="b">Shanghai</RadioButton>
|
||||
<RadioButton value="c">Beijing</RadioButton>
|
||||
<RadioButton value="d">Chengdu</RadioButton>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@ -29,6 +37,7 @@ export default {
|
||||
],
|
||||
value: '1',
|
||||
value1: '',
|
||||
value2: 'a',
|
||||
showMore: false,
|
||||
}
|
||||
},
|
||||
@ -46,6 +55,7 @@ export default {
|
||||
components: {
|
||||
Radio,
|
||||
RadioGroup: Radio.Group,
|
||||
RadioButton: Radio.Button,
|
||||
AntButton: Button,
|
||||
},
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
"babel-helper-vue-jsx-merge-props": "^2.0.2",
|
||||
"babel-loader": "^7.1.2",
|
||||
"babel-plugin-syntax-jsx": "^6.18.0",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-plugin-transform-vue-jsx": "^3.5.0",
|
||||
"babel-preset-env": "^1.6.0",
|
||||
"css-loader": "^0.28.7",
|
||||
|
Loading…
Reference in New Issue
Block a user