鍍金池/ 問(wèn)答/網(wǎng)絡(luò)安全  HTML/ vue router 重定向后地址改變了內(nèi)容沒變,求解

vue router 重定向后地址改變了內(nèi)容沒變,求解

想實(shí)現(xiàn)的效果是如果自己輸入地址:localhost:8080/detail/detail 可以跳轉(zhuǎn)至 localhost:8080/detail/detailInfo,現(xiàn)在地址可以,但是內(nèi)容還是localhost:8080/detail/detail下的內(nèi)容
路徑:
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 // 登錄頁(yè)面
    },
    {
      path: '/login',
      component: Login // 登錄頁(yè)面
    },
    {
      path: '/welcome',
      component: Welcome // 登錄頁(yè)面
    },
    {
      path: '',
      component: Common, // 原來(lái)的 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 
          }
        }
      ]
    }
  ]
})
回答
編輯回答
祉小皓

你這寫的是從/detail跳到/detail/detailInfo啊,也就是組件detialPage換成了detialInfo

2017年3月23日 11:35
編輯回答
乞許
path:'/detial/detial' //你這里路徑是不是沒寫對(duì)?
2017年11月23日 05:45