zoukankan      html  css  js  c++  java
  • vue-router-7-重定向及别名

    const router = new VueRouter({
      mode: 'history',
      base: __dirname,
      routes: [
        { path: '/', component: Home,
          children: [
            { path: '', component: Default },
            { path: 'foo', component: Foo },
            { path: 'baz', name: 'baz', component: Baz },
            { path: 'with-params/:id', component: WithParams },
            // relative redirect to a sibling route
            { path: 'relative-redirect', redirect: 'foo' }
          ]
        },
        // absolute redirect
        { path: '/absolute-redirect', redirect: '/bar' },
        // dynamic redirect, note that the target route `to` is available for the redirect function
        { path: '/dynamic-redirect/:id?',
          redirect: to => {
            const { hash, params, query } = to
            if (query.to === 'foo') {
              return { path: '/foo', query: null }
            }
            if (hash === '#baz') {
              return { name: 'baz', hash: '' }
            }
            if (params.id) {
              return '/with-params/:id'
            } else {
              return '/bar'
            }
          }
        },
        // named redirect
        { path: '/named-redirect', redirect: { name: 'baz' }},
    
        // redirect with params
        { path: '/redirect-with-params/:id', redirect: '/with-params/:id' },
    
        // catch all redirect
        { path: '*', redirect: '/' }
      ]
    })

    别名

    const router = new VueRouter({
      routes: [
        { path: '/a', component: A, alias: '/b' }
      ]
    })
  • 相关阅读:
    springboot1.x+dubbo案例
    dubbo相关的博文
    druid监控配置
    Tomcat启动报错整理
    Hibernate @OneToMany等注解设置查询过滤条件等
    异常处理
    复杂的xml转化为java实体
    简单Java类与XML之间的转换
    mysql errno 150
    JdbcTemplate进行查询
  • 原文地址:https://www.cnblogs.com/avidya/p/7646619.html
Copyright © 2011-2022 走看看