<template>
  <div class="dv-dropdown-menu-item" :class="{active: active}" @click="handleClick">
    <slot></slot>
  </div>
</template>

<script>
  import Emitter from 'canknow-ui-core/src/mixins/emitter';

  export default {
    name: 'DvDropdownMenuItem',
    mixins: [Emitter],
    props: {
      value: null
    },
    data () {
      return {
        active: false
      };
    },
    methods: {
      handleClick () {
        this.dispatch('DvDropdownMenu', 'select', this.value);
      }
    },
    mounted() {
      this.$on('selectItem', (value) => {
        this.active = value === this.value;
      })
    }
  };
</script>
