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

TabBar 组件内 获取路由名称为undefined #132

Closed
sorkhan opened this issue Nov 9, 2024 · 1 comment
Closed

TabBar 组件内 获取路由名称为undefined #132

sorkhan opened this issue Nov 9, 2024 · 1 comment

Comments

@sorkhan
Copy link

sorkhan commented Nov 9, 2024

在components/TabBar.vue 文件内,获取 route.name 值时console显示undefined。 如下图。
image)

@sorkhan sorkhan closed this as completed Nov 9, 2024
@sorkhan sorkhan reopened this Nov 9, 2024
@CharleeWa
Copy link
Collaborator

@sorkhan 感谢反馈,这可能是因为应用初始加载时,路由还没有完全初始化。使用 watch 函数监听一下,就能看到这个过程了。

watch(route, () => {
  console.log(route.name)
}, { immediate: true })

// undefined
// xxx name

我应该加一下判断来处理这种情况。

const show = computed(() => {
  if (route.name) {
    return routeWhiteList.includes(route.name)
  }
  return false
})

CharleeWa added a commit that referenced this issue Nov 10, 2024
qiyue2015 added a commit to qiyue2015/vue3-vant-mobile that referenced this issue Dec 14, 2024
* commit '259063b2721d3cc1e820fa1f01864f49539d04a0': (30 commits)
  feat: Add documentation cell
  feat: remove screen adaptation prompt
  feat: Improve the prompt for screen adaptation in night mode
  feat: add screen adaptation prompt
  chore: release v3.4.0
  feat: Support JSON5 (easy-temps#136)
  chore: Update all deps
  chore: release v3.3.1
  chore: Apply lint
  chore: Update vite deps optimization config
  chore: Update to vite 6
  chore: pin typescript - vuejs/language-tools#5018
  chore: Update all deps
  perf: control the nested display of related files for vscode (easy-temps#135)
  chore: release v3.3.0
  refactor: combine vant i18n setup (easy-temps#133)
  feat: Lazy loading the localization files
  chore: release v3.2.1
  chore: Update editorconfig
  fix: Add `route.name` null check (easy-temps#132)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants