Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabScroll.vue报空错误 #131

Closed
jktantan opened this issue Nov 1, 2021 · 2 comments
Closed

TabScroll.vue报空错误 #131

jktantan opened this issue Nov 1, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@jktantan
Copy link

jktantan commented Nov 1, 2021

Bug 描述

在跳出有router-tab组件的页面时,如果鼠标正好处理tabscroll,会出现‘TypeError: Cannot read properties of undefined (reading 'clientWidth')’的错误。

问题重现

重现行为的步骤:

  1. 跳出e router-tab组件的页面
  2. 鼠标在这期间正好处于tab-scroll的范围。
  3. 此时会激发mouseenter的行为,进行update处理,在update中this.$refs.container会获取到null,导致出错。

关键代码

   // 更新滚动数据
    update() {
      const { clientWidth, scrollWidth, scrollLeft } = this.$refs.container

      // 判断是否移动端
      // userAgent 中包含 mobile 字段,或者浏览器滚动条宽度为 0
      this.isMobile =
        /mobile/i.test(navigator.userAgent) || !getScrollbarWidth()

      Object.assign(this.scrollData, { clientWidth, scrollWidth, scrollLeft })
    },

开发环境(请填写以下信息)

  • Nuxtjs
@jktantan jktantan added the bug Something isn't working label Nov 1, 2021
bhuh12 pushed a commit that referenced this issue Nov 5, 2021
@bhuh12
Copy link
Owner

bhuh12 commented Nov 5, 2021

v1.2.8 已发布,请更新试试

@jktantan
Copy link
Author

jktantan commented Nov 5, 2021

已解决问题

@jktantan jktantan closed this as completed Nov 5, 2021
bhuh12 added a commit that referenced this issue Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants