Home > Web Front-end > JS Tutorial > Nested routing (sub-routing) of Vue.js

Nested routing (sub-routing) of Vue.js

php中世界最好的语言
Release: 2018-03-13 14:39:30
Original
2014 people have browsed it

This time I will bring you the nested routing of Vue.js (sub-routing). What are the precautions when using Vue.js nested routing (sub-routing)? The following is a practical case, let’s take a look.

children
Nested routing, the child routing is inserted into the parent component apple

let router = new VRouter({ // 如果mode设为history, 那么地址就可以不使用哈希(# 哈希)了,就可以直接访问. http://localhost:8080/#/apple ==>> http://localhost:8080/apple
  mode: 'history',  routes: [    //  做一个映射表
    {      path: '/apple',      component: Apple,      // 嵌套路由,子路由插入到了父组件apple中
      children: [
        {          path: 'red',          component: RedApple
        }
      ]
    },
    {      path: '/banana',      component: Banana
    }
  ]
})
Copy after login

In the parent routing apple component, insert the RedApple component

<template>  <div class="hello">
    .......    <router-view></router-view>
  </div></template>
Copy after login

Nested routing (sub-routing) of Vue.js

to red apple
<router-link :to="{path:&#39;apple/red&#39;}">to red apple</router-link>
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website Other related articles!

Recommended reading:

Vue tag attributes and conditional rendering of Vue.js

What should you pay attention to when using Vue.js matter

The above is the detailed content of Nested routing (sub-routing) of Vue.js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template