我们正在使用 Ant Design 项目的工具提示。我们希望这些工具提示在悬停后消失。
import React, { useState } from 'react';
import styled from 'styled-components';
import { Tooltip } from 'antd';
import Highlighter from 'react-highlight-words';
const TooltipText = ({
children,
className,
tabIndex,
fontSize,
padding,
highlightWord,
style = { 'white-space': 'nowrap' },
toolTipPlacement = 'top',
clickable = true,
onClick,
}) => {
const [truncated, setTruncated] = useState(false);
const updateOverflow = e => {
const el = e.currentTarget;
if (el.classList.contains('detail-location')) {
const canvasContext = document.createElement('canvas').getContext('2d');
if (
Math.ceil(canvasContext.measureText(el.innerText).width) >
2 * el.clientWidth …Run Code Online (Sandbox Code Playgroud)