当 hover 上物体时, 显示遮罩
https://codepen.io/dream2023/pen/oRJOGB/
npm install vue-hover-mask --save
// 全局引入
import VueHoverMask from 'vue-hover-mask'
Vue.component(VueHoverMask.name, VueHoverMask)
// 局部引入
import VueHoverMask from 'vue-hover-mask'
export default {
components: {
VueHoverMask
}
}
<template>
<!-- click事件 -->
<vue-hover-mask @click="handleClick">
<!-- 默认插槽 -->
<img
src="http://t.cn/Ai9b5w8V"
style="width: 200px;height: 200px;object-fit: cover;"
/>
<!-- action插槽 -->
<template v-slot:action>
<i class="iconfont zoom"></i>
<i class="iconfont delete"></i>
</template>
</vue-hover-mask>
</template>
<script>
export default {
methods: {
handleClick() {
console.log('click')
}
}
}
</script>
<style>
@import url('//at.alicdn.com/t/font_1223885_a68qqkvtjgr.css');
.iconfont {
font-size: 24px;
}
</style>