使用DataV轮播表dv-scroll-board添加移入显示tooltip功能

项目需求给 dv-scroll-board轮播表添加移入提示, 但DataV文档没有提示框tooltip的属性

DataV官方文档的轮播表 如果有tooltip 请@我一下😀

在这里插入图片描述

话不多说 ,直接上菜

<!-- Vue 2 Code -->
<template>
      <div @mousemove="move">
          <div class="table" @mouseleave="leave">
            <dv-scroll-board
              :config="config"
              :key="key"
              @mouseover="over"
            />
            <p
              v-if="tipShow"
              class=tip-text"
              :style="{ top: tipText.offsetY, left: tipText.offsetX}"
            >
              {{ tipText.name }}
            </p>
          </div>
      </div>
 </template>
 <script>
 export default {
  name: "list",
  data() {
		return {
		     // 轮播表属性
		     config: {...},
		     // tooltip
		     tipText: {
		        name: "",
		        offsetX: "",
		        offsetY: "",
		     },
		     tipShow: false, // 控制单元格显隐
		};
   },
   methods: {
      // 鼠标移入
      over(dom) {
	    	this.tipShow= true;
	    	//v.ceil拿到单元格数据
	    	const htmlString = dom.ceil;
	    	const regex = /<div[^>]*>(.*?)<\/div>/;
	    	const match = regex.exec(htmlString);
	    	this.tipText.name = match ? match[1] : "";
	   		//没有值则直接隐藏悬浮框
	    	if(!this.tipText.name) this.tipShow = false;
	 },
     // 鼠标移动
     move(e) {
      		const { left, top } = e.currentTarget.getBoundingClientRect();
      		const xPosition = e.pageX - left;
      		const yPosition = e.pageY - top;
      		// 悬浮框位置可自行调整
      		this.tipText.offsetX = xPosition + "px";
      		this.tipText.offsetY= yPosition + "px";
     },
     // 鼠标离开
	 leave() {
	      	//隐藏单元格
	     	this.tipShow= false;
	 },
    }
 };
 </script>
 <style  lang='scss' scoped>
 .ceil {
  position: relative;
 }
 .tip-text {
  background: #000000;
  padding: 5px;
  font-size: 14px;
  // z-index: 200;
  position: absolute;
  left: 0;
  top: 0;
  text-align: center;
 }
</style>

提示:移入轮播表时 ,如果没有悬停效果,更新一下版本 @jiaminghi/data-view版本。亲测2.7.3版本没有悬停

  • 9
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

水煮白菜王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值