Vue动态添加router路由

this.$router.addRoutes();

参数是一个数组,里面的对象就是添加上去的路由。

例子:

this.$router.addRoutes([

                {

                //测试专用

                path:'/ceshi',

                name:'ceshi',

                component:pathMap['/ceshi']

                },

                {

                //菜单管理页面

                path:'/MenuManagement',

                name:'MenuManagement',

                component:pathMap['/MenuManagement']

                },

                {

                //角色管理页面

                path:'/RoleManagement',

                name:'RoleManagement',

                component:pathMap['/RoleManagement']

                },

                {

                //用户信息管理页面

                path:'/UserInformationManagement',

                name:'UserInformationManagement',

                component:pathMap['/UserInformationManagement']

                }

        ]);

跳转到指定路由:

this.$router.push();

参数可以是一个字符串。

例子:

this.$router.push("/MenuManagement");

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容