fix(projects): 添加西瓜视频实例在onUnMounted的销毁,多页签居中距离精确

This commit is contained in:
Soybean
2021-11-25 22:16:34 +08:00
parent c429cd0293
commit 738964a769
2 changed files with 12 additions and 6 deletions

View File

@ -71,13 +71,13 @@ function setDropdownConfig(x: number, y: number, currentPath: string) {
// 获取当前激活的tab的clientX
const tabRef = ref<HTMLElement | null>(null);
async function getActiveChromeTabClientX() {
async function getActiveTabClientX() {
await nextTick();
const index = app.activeMultiTabIndex;
if (tabRef.value) {
const activeTabElement = tabRef.value.children[index];
const { x, width } = activeTabElement.getBoundingClientRect();
const clientX = x + width;
const clientX = x + width / 2;
setTimeout(() => {
emit('scroll', clientX);
}, 50);
@ -103,7 +103,7 @@ useEventListener(window, 'beforeunload', () => {
watch(
() => app.activeMultiTabIndex,
() => {
getActiveChromeTabClientX();
getActiveTabClientX();
},
{
immediate: true