html部分

 <div class="img-preview" v-for="(img,i) of list" :key="img.imageKey" v-on:mouseenter="changeActive(i+1)" v-on:mouseleave="removeActive(i+1)" :id="i+1"> //这样就给循环出来的div添加了不同的id
            <div class="mask"></div>
            <i class="el-icon-delete" @click.prevent="delImg(i)" style="display: none;"></i>
            <img class="imgstyle"
                    :src="img.imageUrl || img.thumbUrl"
                    alt=""
                    @click="openNewImg(img.imageUrl || img.url)"
            />
        </div>

js部分

changeActive(index){
                console.log($('#'+index ));
                $('#'+index ).find('.el-icon-delete').show();
            },
            removeActive(index){
                $('#'+index ).find('.el-icon-delete').hide();
            },

转载于:https://www.cnblogs.com/lml-lml/p/9294456.html

Logo

前往低代码交流专区

更多推荐