vue音乐播放器项目 二级路由跳转

1.  在 index.js 设置子路由

import TopList from '@/pages/disc/disc'

{   
  path: '/recommend', name: 'Recommend', component: Recommend, children: [ { path: ':id', component: Disc } ] }

 

2.  在 template 中插入 <router-view></router-view>

 

3.  在需要点击的位置设置点击事件 @click="selectItem(item)"

 

4.  设置方法

methods: {
    selectItem(item) {
      this.$router.push({
          path: `/recommend/${item.dissid}`
      })
    }
}

 

posted on 2018-07-31 15:15  素~  阅读(169)  评论(0编辑  收藏  举报