feat(router): 增加页面 title
增加页面 title Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
parent
306e54bcd5
commit
931fecd152
@ -40,22 +40,26 @@ const routes = [
|
||||
{
|
||||
path: '/recipe-mobile/recipe/create/',
|
||||
name: "RecipeMobileRecipeCreate",
|
||||
component: RecipeMobileRecipeCreate
|
||||
component: RecipeMobileRecipeCreate,
|
||||
meta: {title: '创建菜谱'}
|
||||
},
|
||||
{
|
||||
path: '/recipe-mobile/week-recipe/',
|
||||
name: "RecipeMobileWeekRecipe",
|
||||
component: RecipeMobileWeekRecipe
|
||||
component: RecipeMobileWeekRecipe,
|
||||
meta: {title: '每周菜谱'}
|
||||
},
|
||||
{
|
||||
path: '/recipe-mobile/recipe/:id',
|
||||
name: "RecipeMobileRecipeDetail",
|
||||
component: RecipeMobileRecipeDetail
|
||||
component: RecipeMobileRecipeDetail,
|
||||
meta: {title: '菜谱'}
|
||||
},
|
||||
{
|
||||
path: '/recipe-mobile/daily-recipe/:id',
|
||||
name: "RecipeMobileDailyRecipeDetail",
|
||||
component: RecipeMobileDailyRecipeDetail
|
||||
component: RecipeMobileDailyRecipeDetail,
|
||||
meta: {title: '每日菜谱'}
|
||||
},
|
||||
];
|
||||
|
||||
@ -64,4 +68,10 @@ const router = createRouter({
|
||||
routes,
|
||||
});
|
||||
|
||||
const defaultTitle = '今天吃什么';
|
||||
router.beforeEach((to, from, next) => {
|
||||
document.title = to.meta.title ? to.meta.title : defaultTitle;
|
||||
next();
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user