import domAlign from 'dom-align'; import { DATA_ELEMENT } from '../../constants/root'; import { NodeInterface } from '../../types/node'; import { Placement } from '../../types/position'; import { $ } from '../../node'; import { getDocument } from '../../utils'; import placements from '../../position/placements'; import './index.css'; const template = (options: { placement: Placement }) => { return `
`; }; class Tooltip { static show( node: NodeInterface, title: string | NodeInterface, options: { placement: Placement } = { placement: 'top' }, ) { Tooltip.hide(); const root = $(template(options)); // 设置提示文字 if (typeof title === 'string') root.find('[data-role=tooltip]').html(title); else root.find('[data-role=tooltip]').append(title); // 计算定位 const doc = getDocument(); const body = $(doc.body); body.append(root); const rect = domAlign( root.get