<template>
  <div class="e-checkbox">
    <slot></slot>
  </div>
</template>
<script>
  export default{
    name:'emmm-checkbox',
    data(){
      return {

      }
    },
    props:{
      value: {
        type: Array,
        default:function(){
          return Array;
        }
      }
    },
    watch: {
      value (val) {
        this.updateValue()
      }
    },
    methods: {
      updateValue () {
        const value = this.value
        this.childrens = this.$children.filter(item => item.$options.name === 'emmm-checkbox-item')
        if (this.childrens) {
          this.childrens.forEach(child => {
            child.checkedModels = value
          })
        }
      },
    change (val) {
        this.$emit('input', val)
      }
    },
    mounted () {
        this.$nextTick(this.updateValue)
    }
}
</script>
<style>
  @import './checkbox.css';
</style>
