diff --git a/docs/examples-docs/radio.md b/docs/examples-docs/radio.md
index 3d99958c0..cf62937f7 100644
--- a/docs/examples-docs/radio.md
+++ b/docs/examples-docs/radio.md
@@ -12,11 +12,9 @@ export default {
### 基础用法
-:::demo
```html
-
+单选框
```
-:::
### API
diff --git a/docs/examples/dialog.vue b/docs/examples/dialog.vue
index dd6a8b30d..c17c07476 100644
--- a/docs/examples/dialog.vue
+++ b/docs/examples/dialog.vue
@@ -14,7 +14,8 @@
diff --git a/docs/index.js b/docs/index.js
index 23b8c79ec..dee3b3d5b 100644
--- a/docs/index.js
+++ b/docs/index.js
@@ -5,13 +5,7 @@ import navConfig from './nav.config.json';
import routes from './router.config';
import SideNav from './components/side-nav';
import Mobile from './components/mobile';
-import ZanUI from '../src/index';
-import '../packages/zanui-css/src/index.css';
-
-import { Dialog } from '../src/index';
-console.log(Dialog);
-Vue.use(ZanUI);
Vue.use(VueRouter);
Vue.component('side-nav', SideNav);
Vue.component('mobile', Mobile);
diff --git a/packages/radio/src/radio-group.vue b/packages/radio/src/radio-group.vue
index 157922b3b..6e6b774c6 100644
--- a/packages/radio/src/radio-group.vue
+++ b/packages/radio/src/radio-group.vue
@@ -9,7 +9,14 @@ export default {
name: 'z-radio-group',
props: {
- value: [String, Number]
+ value: {},
+ disabled: Boolean
+ },
+
+ watch: {
+ value(value) {
+ this.$emit('change', value);
+ }
}
};
diff --git a/packages/radio/src/radio.vue b/packages/radio/src/radio.vue
index e51e1db7c..503d1298a 100644
--- a/packages/radio/src/radio.vue
+++ b/packages/radio/src/radio.vue
@@ -2,10 +2,15 @@
-
+
@@ -21,35 +26,50 @@ export default {
props: {
disabled: Boolean,
value: {},
- parentGroup: null
+ name: [String, Number]
},
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;
+ return !!this.findRadioGroup()
},
- model: {
+ currentValue: {
get() {
return this.isGroup ? this.parentGroup.value : this.value;
},
set(val) {
if (this.isGroup) {
-
+ this.parentGroup.$emit('input', val);
} else {
this.$emit('input', val);
}
}
+ },
+
+ isDisabled() {
+ return this.isGroup
+ ? this.parentGroup.disabled || this.disabled
+ : this.disabled;
+ }
+ },
+
+ methods: {
+ findRadioGroup() {
+ if (this.parentGroup) return;
+
+ let parent = this.$parent;
+ while (parent) {
+ if (parent.$options.name === 'z-radio-group') {
+ this.parentGroup = parent;
+ break;
+ } else {
+ parent = parent.$parent;
+ }
+ }
+
+ return this.parentGroup;
}
}
};