update Checkbox

update Checkbox
This commit is contained in:
梁灏 2017-03-15 17:56:50 +08:00
parent 3f281d6ce0
commit 99cde29d04
3 changed files with 31 additions and 21 deletions

View file

@ -22,6 +22,7 @@
</label>
</template>
<script>
import { findComponentUpward } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-checkbox';
@ -51,7 +52,8 @@
model: [],
currentValue: this.value,
group: false,
showSlot: true
showSlot: true,
parent: findComponentUpward(this, 'CheckboxGroup')
};
},
computed: {
@ -83,16 +85,11 @@
}
},
mounted () {
// todo 使 while
if (this.$parent && this.$parent.$options.name === 'CheckboxGroup') this.group = true;
this.parent = findComponentUpward(this, 'CheckboxGroup');
if (this.parent) this.group = true;
if (!this.group) {
this.updateModel();
// if (this.$refs.slot && this.$refs.slot.innerHTML === '') {
// this.showSlot = false;
// }
if (this.$slots.default === undefined) {
this.showSlot = false;
}
this.showSlot = this.$slots.default === undefined;
}
},
methods: {
@ -106,7 +103,7 @@
this.$emit('input', checked);
if (this.group) {
this.$parent.change(this.model);
this.parent.change(this.model);
} else {
this.$emit('on-change', checked);
this.dispatch('FormItem', 'on-form-change', checked);