vue 鼠標移入移出 列表蒙層展示


<template>
    <section class="base">
        <ul>
            <li v-for="(item, index) in 20" v-on:mouseenter="showDialog(index)" v-on:mouseleave="hideDialog(index)" :accesskey="index" style="position: relative;width: 100px;height: 50px;">
                {{index}}
                <!--操作蒙層-->
                <div class="handleDialog" v-if="ishow && index==current"></div>
            </li>
        </ul>
    </section>
</template>
<script>
    export default {
        data() {
            return {
                ishow: false,
                current: 0, //當前操作按鈕

            };
        },
        methods: {
            //顯示操作項
            showDialog(index, item) {
                this.ishow = true;
                this.current = index;
            },
            //隱藏蒙層
            hideDialog(index, item) {
                this.ishow = false;
                this.current = null;
            },
        }
    };
</script>
<style lang="less">
    .handleDialog {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 2;
        background: rgba(0, 0, 0, 0.6);
        width: 100%;
        height: 100%;
        border-radius: 4px;
    }
</style>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM