vue router2.0二級路由的簡單使用
更新時間:2017年07月05日 14:19:04 作者:Drox
這篇文章主要為大家詳細介紹了vue router2.0二級路由的簡單使用,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue router2.0二級路由的具體代碼,供大家參考,具體內容如下
1、app.vue中
<template> <div id="app"> <router-view></router-view> </div> </template>
2、router中index.js(路由的路徑配置)
import Vue from 'vue' import Router from 'vue-router' import Hello from '@/components/Hello' import Login from '@/components/Login' import index from '@/components/index' import Header from '@/components/Header/Header' import Product from '@/components/Product/Product' Vue.use(Router) export default new Router({ routes: [ { path: '/', name: 'Login', component: Login }, { path: '/index', name: 'index', component: index, children: [ //這里就是二級路由的配置 { path: '/hello', name: 'Hello', component: Hello }, { path: '/header', name: 'Header', component: Header }, { path: '/product', name: 'Product', component: Product } ] } ] })
3、下面是我們的index.vue中的代碼
<template> <div class="aaa"> <div class="list-group"> <router-link to="/hello">Go to hello</router-link> <router-link to="/header">Go to header</router-link> <router-link to="/product">Go to product</router-link> <input type="text" v-model="username"> <button v-click="text"></button> <router-view></router-view> </div> </div> </template>
4、最后就是新建hello、header、product這幾個組件來驗證我們的效果,這里就不做演示了,因為我自己已經測試過了,沒有問題
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
Vue+elementUI實現多圖片上傳與回顯功能(含回顯后繼續(xù)上傳或刪除)
這篇文章主要介紹了Vue+elementUI實現多圖片上傳與回顯功能(含回顯后繼續(xù)上傳或刪除),本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-03-03Vue如何整合mavon-editor編輯器(markdown編輯和預覽)
這篇文章主要介紹了Vue整合mavon-editor編輯器(markdown編輯和預覽)的相關知識,mavon-editor是目前比較主流的markdown編輯器,重點介紹它的使用方法,需要的朋友可以參考下2022-10-10element el-tree組件的動態(tài)加載、新增、更新節(jié)點的實現
這篇文章主要介紹了element el-tree組件的動態(tài)加載、新增、更新節(jié)點的實現,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-02-02