定义路由地址:
const routes = [{
path: ‘/’,
name: ‘index’,
component: index,
//此处的meta 中的title 即为 微信的头部标签名
meta: {
title: " 活动报名"
},
},
{
path: ‘/indexApply’,
name: ‘indexApply’,
component: indexApply,
meta: {
title: " 活动报名"
},
},}]
const router = new Router({
mode: ‘hash’,
routes: routes
})
router.beforeEach((to, from, next) => {
if (to.meta.title) {
document.title = to.meta.title
}
next();
})
将路由地址暴露出去
export default router;

本文详细介绍如何在Vue.js项目中定义和配置路由,包括设置路由地址、组件映射及利用meta属性自定义页面标题,实现页面切换时动态更新浏览器tab标题的功能。
3748

被折叠的 条评论
为什么被折叠?



