接着上一章讲一下vue路游中的多重路游吧

1.创建vue组件,comingsoon.vue和nowplaying.vue

2.修改配置文件,这里路游到film.vue组件中

import Vue from 'vue'
import Router from 'vue-router'
import Gard from '@/components/Card.vue'
import Film from '@/components/Film.vue'
import Home from '@/components/Home.vue'
import NowPlaying from '@/components/nowplaying.vue'
import ComingSoon from '@/components/comingsoon.vue'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: Gard
    },
    {
      path: '/g',
      component: Gard
    },
    {
      path: '/f',
      component: Film,
      children: [
        {
          path: 'row-playing',
          component: NowPlaying
        },
        {
          path: 'coming-soon',
          component: ComingSoon
        }
      ]
    },
    {
      path: '/h',
      component: Home
    }
  ]
})


多重路游就是在当前节点下创建children节点

然后我们在film文件中添加reuter-view节点,以此来路游



标签: vue, vue-cli

添加新评论