import Vue from 'vue'import Router from 'vue-router'import Hello from '@/components/Hello'import Apple from '@/components/apple';import Banbana from '@/components/banbana';import RedApple from '@/components/redapple';Vue.use(Router);export default new Router({ mode: 'history', routes: [ //路由配置 { path: '/', component: Hello }, { path: '/apple', component: Apple, children: [ { path: 'red', component: RedApple } ] }, { path: '/banbana', component: Banbana } ]})以上代碼中 8080/ 是輸出組件Hello是正確的 , 8080/apple 輸入的是組件apple也是正確的 , 但是輸入8080/apple/red 的時(shí)候不會(huì)跳轉(zhuǎn)到 path:'red'對(duì)應(yīng)的子組件RedApple中。用import RedApple from '../components/redapple'的方法在 components : {RedApple} 注冊(cè)后在頁(yè)面中使用 <RedApple></RedApple> 是可以直接輸出 RedApple里面的內(nèi)容的,而使用路由卻不行,這是為什么呢?本人剛剛開(kāi)始學(xué)習(xí)vue.js不久... 求大佬們指點(diǎn)!謝謝大家!
vue.js中使用router路由設(shè)置后children的component失效。
飲歌長(zhǎng)嘯
2018-12-21 19:14:46