跳至主要內容

Vue2 动态切换网页标题

望间代码VueVue2小于 1 分钟

Vue2 动态切换网页标题

在路由文件中实现

const routes = [
  {
    path: "/home",
    compontent: Home,
    meta: { title: "首页" },
  },
];
router.afterEach((to, from) => {
  /* 网页标题 */
  document.title = to.meta.title;
});
上次编辑于:
贡献者: ViewRoom