vue router 重定向后地址改变了内容没变,求解

想实现的效果是如果自己输入地址:localhost:8080/detail/detail 可以跳转至 localhost:8080/detail/detailInfo,现在地址可以,但是内容还是localhost:8080/detail/detail下的内容
路径:
import detialPage from '../components/detial/detial'
import detialInfo from '../components/detial/detialInfo'

clipboard.png

{
          path:'/detial',
          component: detialPage,
          children:[
            {
              path:'detialInfo',
              component:detialInfo,
              meta: { 
                requiresAuth: true 
              }
            }
          ],
          redirect:'/detial/detialInfo',
          meta: {
            requiresAuth: true 
          }
        }

全部配置

import Vue from 'vue'
import Router from 'vue-router'
import Index from '../components/index'
import Classify from '../components/classify'
import Cart from '../components/cart'
import Center from '../components/center'
import Welcome from '../components/welcome'
import Login from '../components/login'
import Common from '../common'
import father from '../components/father'
import detialPage from '../components/detial/detial'
import detialInfo from '../components/detial/detialInfo'
Vue.use(Router)



export default new Router({
    mode: 'history',
  routes: [
    {
      path: '/f',
      component: father // 登录页面
    },
    {
      path: '/login',
      component: Login // 登录页面
    },
    {
      path: '/welcome',
      component: Welcome // 登录页面
    },
    {
      path: '',
      component: Common, // 原来的 App.vue
      children: [
        {
          path:'/detial',
          component: detialPage,
          children:[
            {
              path:'detialInfo',
              component:detialInfo,
              meta: { 
                requiresAuth: true 
              }
            }
          ],
          redirect:'/detial/detialInfo',
          meta: {
            requiresAuth: true 
          }
        },
        {
          path: '/',
          component: Index,
          meta: { 
            requiresAuth: true 
          }
        },
        {
          path: '/classify',
          component: Classify,
          meta: { 
            requiresAuth: true 
          }
        },
        {
          path: '/cart',
          component: Cart,
          meta: { 
            requiresAuth: true 
          }
        },
        {
          path: '/center',
          component: Center,
          meta: { 
            requiresAuth: true 
          }
        }
      ]
    }
  ]
})
阅读 4.2k
2 个回答
path:'/detial/detial' //你这里路径是不是没写对?

你这写的是从/detail跳到/detail/detailInfo啊,也就是组件detialPage换成了detialInfo

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题