select-comp.vue 1.48 KB
<template>
    <div class="select-comp">
        <div class="select-comp__mask__btn" @click="cb && cb($event)">编辑</div>
        <div v-if="showDelete" class="select-comp__mask__btn__del" @click="del && del($event)">删除</div>
        <div class="select-comp__mask"></div>
        <slot></slot>
    </div>
</template>

<script>
  export default {
    name: 'select-comp',
    props: ['cb', 'del', 'showDelete']
  }
</script>

<style>
    .select-comp {
        position: relative;
    }

    .select-comp:hover .select-comp__mask {
        display: block;
    }

    .select-comp__mask {
        position: absolute;
        display: none;
        width: 100%;
        height: 100%;
        background-color: rgba(255, 255, 255, 0.5);
    }

    .select-comp:hover .select-comp__mask__btn {
        display: block;
    }

    .select-comp:hover .select-comp__mask__btn__del {
        display: block;
    }

    .select-comp__mask__btn {
        z-index: 90;
        width: 60px;
        height: 20px;
        position: absolute;
        display: none;
        top: 0;
        right: 0;
        cursor: pointer;
        color: white;
        background-color: gray;
        text-align: center;
    }

    .select-comp__mask__btn__del {
        z-index: 90;
        width: 60px;
        height: 20px;
        position: absolute;
        display: none;
        top: 0;
        right: 60px;
        cursor: pointer;
        color: white;
        background-color: red;
        text-align: center;
    }
</style>