Skip to content

是否可以让顶部标签栏的名称动态修改为自定义的名称? #676

Answered by crazywhalecc
crazywhalecc asked this question in Q&A
Discussion options

You must be logged in to vote

谢谢提示,我最终没用动态路由,看了下 menu nav tab 的源码,应该是使用了 routerStore 作为数据绑定,我只需要在当前页面找到当前页面的路由后修改 title 就成功了。代码如下:

const tmps = `/project/${projectId.value}/info`;
  tabsRouterStore.tabRouters.forEach((x) => {
    if (x.name === 'project-info' && x.path === tmps) {
      console.log(tmpProjectInfoData.value);
      x.title = `项目详情-${tmpProjectInfoData.value.project_name}`;
      router.currentRoute.value.meta.title = `项目详情-${tmpProjectInfoData.value.project_name}`;
    }
  });

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@crazywhalecc
Comment options

Answer selected by crazywhalecc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants