diff --git a/CHANGE.md b/CHANGE.md index 3e89c5f..ffeca99 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -4,3 +4,7 @@ 使用 v-model ### Radio value 改为了 label,使用 v-model,废弃 checked +### Checkbox +使用 v-model +### CheckboxGroup +value 改为了 label,使用 v-model,废弃 checked \ No newline at end of file diff --git a/README.md b/README.md index 81fe8fc..3244bf3 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ - [x] Icon - [x] Input - [x] Radio -- [ ] Checkbox +- [x] Checkbox - [ ] Switch - [ ] Table - [ ] Select diff --git a/src/components/checkbox/checkbox-group.vue b/src/components/checkbox/checkbox-group.vue index 74f9900..c6e9942 100644 --- a/src/components/checkbox/checkbox-group.vue +++ b/src/components/checkbox/checkbox-group.vue @@ -9,42 +9,49 @@ export default { name: 'checkboxGroup', props: { - model: { + value: { type: Array, default () { return []; } } }, + data () { + return { + currentValue: this.value + }; + }, computed: { classes () { return `${prefixCls}`; } }, - compiled () { + mounted () { this.updateModel(true); }, methods: { updateModel (update) { - const model = this.model; + const value = this.value; this.$children.forEach((child) => { - child.model = model; + child.model = value; if (update) { - child.selected = model.indexOf(child.value) >= 0; + child.currentValue = value.indexOf(child.label) >= 0; child.group = true; } }); }, change (data) { - this.model = data; + this.currentValue = data; + this.$emit('input', data); this.$emit('on-change', data); - this.$dispatch('on-form-change', data); + // todo 事件 +// this.$dispatch('on-form-change', data); } }, watch: { - model () { + value () { this.updateModel(true); } } diff --git a/src/components/checkbox/checkbox.vue b/src/components/checkbox/checkbox.vue index 90d99b7..bc65229 100644 --- a/src/components/checkbox/checkbox.vue +++ b/src/components/checkbox/checkbox.vue @@ -7,7 +7,7 @@ type="checkbox" :class="inputClasses" :disabled="disabled" - :value="value" + :value="label" v-model="model" @change="change"> - {{ value }} + {{ label }} -- libgit2 0.21.4