文字过长, 鼠标悬浮显示vue2,vue3组件

效果

image.png

vue2








vue3







dom.js

// 获取滚动的dom
export function getScrollContainer(el, vertical) {
    let parent = el;
    while (parent) {
        if ([window, document, document.documentElement].includes(parent)) {
            return window;
        }
        if (isScroll(parent, vertical)) {
            return parent;
        }
        parent = parent.parentNode;
    }
    return parent;
}
export function isScroll(el, vertical) {
    const determinedDirection = vertical !== null || vertical !== undefined;
    const overflow = determinedDirection ?
        vertical ?
        getComputedStyle(el)['overflow-y'] :
        getComputedStyle(el)['overflow-x'] :
        getComputedStyle(el)['overflow'];
    return overflow.match(/(scroll|auto)/);
}

你可能感兴趣的:(文字过长, 鼠标悬浮显示vue2,vue3组件)