index.vue 1.45 KB
<template>
  <div class="my-drop-menu">
    <div class="left_widget label flex_cc">
      <el-dropdown trigger="click" @command="onChangeValue">
        <div class="h13_title">
          {{ leftName }}
          <i class="el-icon-caret-bottom el-icon-caret-top"></i>
        </div>
        <el-dropdown-menu slot="dropdown" class="drop_item">
          <el-dropdown-item v-for="item in options" :key="item.value" :command="item">{{item.label}}</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
    <div class="right_widget">
      <slot name="right_con"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: '',
  data() {
    return {}
  },

  props: {
    leftName: {
      type: String,
      default: '请选择'
    },
    options:Array
  },

  mounted() {},
  methods: {
    onChangeValue(e){
      this.leftName = e.label
      this.$emit('getValue',e.value)
    },
  }
}
</script>
<style lang="scss" scoped>
.my-drop-menu {
  display: flex;
  align-items: center;
  padding-left: 15px;
  .left_widget {
    box-sizing: border-box;
    height: 28px;
    border-radius: 4px 0px 0px 4px;
    border: 1px solid #e8e8ea;
    border-right: none;
    cursor: pointer;
  }
  .el-icon-caret-bottom {
    color: #999;
  }
  .label {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
    width: 80px;
  }
}
</style>