Merge branch 'master' into add_switch_animation

This commit is contained in:
jiangruowei 2017-02-22 10:57:26 +08:00
commit 1417f22c3b
5 changed files with 47 additions and 4 deletions

View File

@ -1,3 +1,3 @@
import RadioGroup from '../cell/src/radio-group';
import RadioGroup from 'packages/radio/src/radio-group';
export default RadioGroup;

View File

@ -6,6 +6,10 @@
<script>
export default {
name: 'z-radio-group',
props: {
value: [String, Number]
}
};
</script>

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>

View File

@ -0,0 +1,5 @@
@component-namespace z {
@b radio {
}
}

View File

@ -8,6 +8,7 @@ import CellGroup from '../packages/cell-group/index.js';
import Popup from '../packages/popup/index.js';
import Dialog from '../packages/dialog/index.js';
import Picker from '../packages/picker/index.js';
import RadioGroup from '../packages/radio-group/index.js';
// zanui
import '../packages/zanui-css/src/index.pcss';
@ -23,6 +24,7 @@ const install = function(Vue) {
Vue.component(CellGroup.name, CellGroup);
Vue.component(Popup.name, Popup);
Vue.component(Picker.name, Picker);
Vue.component(RadioGroup.name, RadioGroup);
};
// auto install
@ -42,5 +44,6 @@ module.exports = {
CellGroup,
Popup,
Dialog,
Picker
Picker,
RadioGroup
};