|
@@ -14,9 +14,12 @@ function calculationLocation(el, target, placements) {
|
|
|
|
|
|
el.tooltipPosition.y = 0;
|
|
el.tooltipPosition.y = 0;
|
|
el.tooltipPosition.x = 0;
|
|
el.tooltipPosition.x = 0;
|
|
- let el_dom = el.$el?.nextElementSibling?.getBoundingClientRect() || null
|
|
|
|
- if (!el_dom) return
|
|
|
|
|
|
+ let el_dom = el.$el?.nextElementSibling?.getBoundingClientRect() || target?.w_tipInstance?.$el?.nextElementSibling?.getBoundingClientRect() || null
|
|
let target_dom = target.getBoundingClientRect()
|
|
let target_dom = target.getBoundingClientRect()
|
|
|
|
+ if(!el_dom) {
|
|
|
|
+ console.log('el_dom:不存在', el_dom)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
|
|
if (placements === "left") {
|
|
if (placements === "left") {
|
|
el.tooltipPosition.x = target_dom.x - el_dom.width - 10
|
|
el.tooltipPosition.x = target_dom.x - el_dom.width - 10
|
|
@@ -87,26 +90,24 @@ export const ellipsisTooltip = localStorage.getItem('useEllipseTooltip') ? {
|
|
if (isOverflow(el)) {
|
|
if (isOverflow(el)) {
|
|
const directiveList = allPlacements.filter(placement => binding.modifiers[placement])
|
|
const directiveList = allPlacements.filter(placement => binding.modifiers[placement])
|
|
const placements = directiveList.length ? directiveList : allPlacements
|
|
const placements = directiveList.length ? directiveList : allPlacements
|
|
- console.log('el.w_tooltip-1:', el.w_tooltip)
|
|
|
|
- if (!el.w_tooltip) {
|
|
|
|
- // 创建tooltip实例
|
|
|
|
- const vm = createApp(MyToolTip)
|
|
|
|
- // 创建根元素
|
|
|
|
- el.w_tooltip = document.createElement('div')
|
|
|
|
- // 挂载到页面
|
|
|
|
- document.body.appendChild(el.w_tooltip)
|
|
|
|
- el.w_tooltip.id = `tooltip_${Math.floor(Math.random() * 10000)}`
|
|
|
|
- el.w_tipInstance = vm.mount(el.w_tooltip)
|
|
|
|
- }
|
|
|
|
- console.log('el.w_tooltip-2:', el.w_tooltip)
|
|
|
|
|
|
+ console.log('w_tooltip1:', el.w_tooltip)
|
|
|
|
+ // if (!el.w_tooltip) {}
|
|
|
|
+ // 创建tooltip实例
|
|
|
|
+ const vm = createApp(MyToolTip)
|
|
|
|
+ // 创建根元素
|
|
|
|
+ el.w_tooltip = document.createElement('div')
|
|
|
|
+ // 挂载到页面
|
|
|
|
+ document.body.appendChild(el.w_tooltip)
|
|
|
|
+ el.w_tooltip.id = `tooltip_${Math.floor(Math.random() * 10000)}`
|
|
|
|
+ el.w_tipInstance = vm.mount(el.w_tooltip)
|
|
|
|
+ console.log('w_tooltip2:', el.w_tooltip)
|
|
|
|
+ console.log('w_tipInstance:', el.w_tipInstance)
|
|
// 设置 tooltip 显示方向
|
|
// 设置 tooltip 显示方向
|
|
el.w_tipInstance.placements = placement || placements[0] || 'top'
|
|
el.w_tipInstance.placements = placement || placements[0] || 'top'
|
|
// 设置显示内容
|
|
// 设置显示内容
|
|
el.w_tipInstance.setContent(content || el.innerText)
|
|
el.w_tipInstance.setContent(content || el.innerText)
|
|
// 使 tooltip 显示
|
|
// 使 tooltip 显示
|
|
el.w_tipInstance.showTip()
|
|
el.w_tipInstance.showTip()
|
|
- console.log('el:', el)
|
|
|
|
- console.log('el.w_tipInstance:', el.w_tipInstance)
|
|
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
// 计算 tooltip 在页面中的位置
|
|
// 计算 tooltip 在页面中的位置
|
|
calculationLocation(el.w_tipInstance, el, placements[0])
|
|
calculationLocation(el.w_tipInstance, el, placements[0])
|