VUE 实现 Studio 管理后台(六):鼠标悬停显示弹出窗口

这次介绍的控件相对比较简单,鼠标悬停时显示弹出内容,效果如下:

在这里插入图片描述

为了增加灵活性,用 slot 实现,调用时的代码:

            <MouseOverPop class="toolbox-element">
              <template #heading>
                <div class="element-title"> 服务 </div>
              </template>
              <template #body>
                <div class="pop-content">
                  <img style="width: 100%;" src="images/services.jpg" />
                </div>
              </template>
            </MouseOverPop>

控件代码:

<template>
  <div class="mouse-over-pop" @mouseenter="mouseEnter" @mouseout="mouseOut">
    <slot name="heading"></slot>
    <div v-show="isActive" class="pop-body">
      <slot name="body"></slot>
    </div>
  </div>
</template>

<script> export default {
  name: 'MouseOverPop',
  data() { return {
      isActive: false };
  },

  methods: {
    mouseEnter() { this.isActive = true },
    mouseOut() { this.isActive = false },
  },
} 
</script>

css 代码:

.toolbox-element .element-title{
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  cursor: default;
  color: #c2c2c2;
  font-size: 13px;
  padding:5px 5px;
  margin:3px;
  display: flex;
  flex-flow: row;
  justify-content: space-between;
  align-items: center;
}

.toolbox-element .element-title:hover{
  color: #75b325;
  box-shadow: 2px 2px 5px 0px rgba(0, 0, 0, 0.4); 
}

.toolbox-element{
}

.toolbox-element .pop-content{
  position: absolute;
  top:70px;
  left:100%;
  width: 320px;
  padding:10px;
  background: #eee;
}

最新代码,请到 Github 下载:https://github.com/vularsoft/studio-ui
自行定位相应历史版本即可

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值