码迷,mamicode.com
首页 > 其他好文 > 详细

Vue 重定向和别名

时间:2020-04-21 15:09:14      阅读:53      评论:0      收藏:0      [点我收藏+]

标签:help   use   red   UNC   code   dir   imp   tin   component   

index.js:

import VueRouter from "vue-router";
import UserSettings from "./UserSettings";
import UserEmailsSubscriptions from "./UserEmailsSubscriptions";
import UserProfile from "./UserProfile";
import UserProfilePreview from "./UserProfilePreview";

const routes = [
    {
        path: ‘/user/settings‘,
        // You could also have named views at tho top
        component: UserSettings,
        children: [
            {
                path: ‘emails‘,
                name: ‘emails‘,
                redirect: {name: ‘profile‘},
                // redirect: function (to) {
                //     console.log(to);
                //     return {name: ‘profile‘};
                // },
                component: UserEmailsSubscriptions
            },
            {
                path: ‘profile‘,
                name: ‘profile‘,
                //此路由對應包含了兩個Vue視圖組件
                components: {
                    default: UserProfile,
                    helper: UserProfilePreview
                }
            }]
    }
];

const router = new VueRouter({
    mode: ‘history‘,
    routes,
});


export default router;

技术图片


技术图片

Vue 重定向和别名

标签:help   use   red   UNC   code   dir   imp   tin   component   

原文地址:https://www.cnblogs.com/dzkjz/p/12744424.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!