radio component

This commit is contained in:
cookfront
2017-02-22 10:56:53 +08:00
parent 8782fe99cb
commit 3426ea0ac4
5 changed files with 47 additions and 4 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
import RadioGroup from '../cell/src/radio-group';
import RadioGroup from 'packages/radio/src/radio-group';
export default RadioGroup;
+4
View File
@@ -6,6 +6,10 @@
<script>
export default {
name: 'z-radio-group',
props: {
value: [String, Number]
}
};
</script>
+33 -2
View File
@@ -4,6 +4,10 @@
:class="{
'is-disabled': disabled
}">
<span class="z-radio__input">
<input type="radio" class="z-radio__control">
<span class="z-radio__circle"></span>
</span>
<span class="z-radio__label">
<slot></slot>
</span>
@@ -22,10 +26,37 @@ export default {
props: {
disabled: Boolean,
value: {}
value: {},
parentGroup: null
},
created() {
computed: {
isGroup() {
let parent = this.$parent;
while (parent) {
if (parent.$options.name === 'z-radio-group') {
this.parentGroup = parent;
return true;
} else {
parent = parent.$parent;
}
}
return false;
},
model: {
get() {
return this.isGroup ? this.parentGroup.value : this.value;
},
set(val) {
if (this.isGroup) {
} else {
this.$emit('input', val);
}
}
}
}
};
</script>
+5
View File
@@ -0,0 +1,5 @@
@component-namespace z {
@b radio {
}
}