support Radio
support Radio
This commit is contained in:
parent
fc7ef07216
commit
06322514c6
13 changed files with 77 additions and 214 deletions
|
@ -11,7 +11,7 @@
|
|||
export default {
|
||||
name: 'radioGroup',
|
||||
props: {
|
||||
model: {
|
||||
value: {
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
|
@ -30,6 +30,11 @@
|
|||
default: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
currentValue: this.value
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
classes () {
|
||||
return [
|
||||
|
@ -42,27 +47,29 @@
|
|||
];
|
||||
}
|
||||
},
|
||||
compiled () {
|
||||
this.updateModel();
|
||||
mounted () {
|
||||
this.updateValue();
|
||||
},
|
||||
methods: {
|
||||
updateModel () {
|
||||
const model = this.model;
|
||||
updateValue () {
|
||||
const value = this.value;
|
||||
this.$children.forEach((child) => {
|
||||
child.selected = model == child.value;
|
||||
child.currentValue = value == child.label;
|
||||
child.group = true;
|
||||
});
|
||||
},
|
||||
change (data) {
|
||||
this.model = data.value;
|
||||
this.updateModel();
|
||||
this.currentValue = data.value;
|
||||
this.updateValue();
|
||||
this.$emit('input', data.value);
|
||||
this.$emit('on-change', data.value);
|
||||
this.$dispatch('on-form-change', data.value);
|
||||
// todo 事件
|
||||
// this.$dispatch('on-form-change', data.value);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
model () {
|
||||
this.updateModel();
|
||||
value () {
|
||||
this.updateValue();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue