update RadioGroup

update RadioGroup
This commit is contained in:
梁灏 2017-03-15 17:44:19 +08:00
parent 4f5d393734
commit 3f281d6ce0
4 changed files with 62 additions and 42 deletions

View file

@ -4,7 +4,7 @@
</div>
</template>
<script>
import { oneOf } from '../../utils/assist';
import { oneOf, findComponentsDownward } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-radio-group';
@ -34,7 +34,8 @@
},
data () {
return {
currentValue: this.value
currentValue: this.value,
childrens: []
};
},
computed: {
@ -55,10 +56,14 @@
methods: {
updateValue () {
const value = this.value;
this.$children.forEach((child) => {
child.currentValue = value == child.label;
child.group = true;
});
this.childrens = findComponentsDownward(this, 'Radio');
if (this.childrens) {
this.childrens.forEach(child => {
child.currentValue = value == child.label;
child.group = true;
});
}
},
change (data) {
this.currentValue = data.value;