zoukankan      html  css  js  c++  java
  • vue-router 动态添加 路由

     动态添加路由可以用了做权限管理。登录后服务器端返回权限菜单,前端动态添加路由  然后在设置菜单

     1、vue-router 有方法router.addRoutes(routes) 动态添加更多的路由规则。参数必须是一个符合 routes 选项要求的数组。

         使用方法 

    this.$router.options.routes[0].children.push({//插入路由
        name:'list',
        path: 'list',
        component: resolve => require(['../template/list.vue'], resolve)//将组件用require引进来
    });
    this.$router.addRoutes(this.$router.options.routes);//调用a
    View Code

    我的路由文件:

    export default new Router({
      routes: [
        {
          path: '/',
     
          component: index,
        },
        {
          path: '/login',
          name: 'login',
          component: login
        }
    
    })
  • 相关阅读:
    修改spring boot 启动logo
    查看jvm常用命令
    intellij IDEA破解
    hdu 新生晚会
    How many prime numbers(素数)
    2077 汉诺塔IV
    Factorial
    双人黑白块
    EasyX
    七夕情人节
  • 原文地址:https://www.cnblogs.com/lst619247/p/10668893.html
Copyright © 2011-2022 走看看