javascript - vue routing beginner questions
PHP中文网
PHP中文网 2017-07-05 10:40:40
0
3
735

1: I am new to Vue and I don’t know much about router-link and router-view. The general questions are as follows:

The existing code structure is as follows, which can be understood as a navigation on the left and a display area on the right

//content.vue
<p class = "row">
    <p id="music_left_menu" class = "col-md-2">
        <h4>推荐</h4>
        <ul class="list-group">
            <li><i class = "fa fa-music"></i><router-link to = "/foundMusic">发现音乐</router-link> </li>
            <li><i class = "fa fa-bullhorn"></i> 私人FM</li>
            <li><i class = "fa fa-youtube-play" ></i> MV</li>
        </ul>
     </p>
     <router-view class="router-view col-md-10"></router-view>
</p>

//router.js
import foundMusic from "../compontents/found_music.vue"
routes:[
    {
        path:"/foundMusic",
        component: foundMusic
    }
] 

After configuring the route, clicking the router-link can effectively render it into the router-view
But what I want is the following structure

<p class = "row">
    <left-menu></left-menu>
     <router-view class="router-view col-md-10"></router-view>
</p>

import leftMenu from './menu_content/left_menu.vue'
export default {
  name: 'musicContent',
  components:{
      leftMenu
  }
}
//left_menu.vue 中的结构如下
<template>
  <p id="music_left_menu" class = "col-md-2">
    <h4>推荐</h4>
    <ul class="list-group">
        <li><i class = "fa fa-music"></i><router-link to = "/foundMusic">发现音乐</router-link> </li>
        <li><i class = "fa fa-bullhorn"></i> 私人FM</li>
        <li><i class = "fa fa-youtube-play" ></i> MV</li>
    </ul>
  </p>
</template>

But at this time, clicking "Discover Music" does not render to the router-view. How should I change this route?
I really don't understand this. Can any expert please explain it?

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!