A router tree component that can be used to represents the routes or items as a tree view.
Basic usage:
1. Import the Vue3RouterTree component.
import { defineComponent } from 'vue'; import Vue3RouterTree from 'vue3-router-tree';
2. Add the component to the template.
<template> <div class="demo"> <vue3-router-tree :items="routes"> </vue3-router-tree> </div> </template>
3. Define your routes as follows:
export default defineComponent({ data() { return { routes: [ { path: '/', name: 'Home', hasIcon: true, }, { path: '/dashboard', name: 'Dashboard', hasIcon: true, }, { path: '/component', name: 'Components', hasIcon: true, children: [ { path: '/alerts', name: 'Alerts', }, { path: '/avatars', name: 'Avatars', }, { path: '/buttons', name: 'Buttons', }, { path: '/forms', name: 'Forms', children: [ { path: '/autocompletes', name: 'Autocompletes', }, { path: '/checkboxes', name: 'Checkboxes', }, ], }, ], }, ], }; }, });
Preview:
Changelog:
v0.1.6 (11/01/2020)
- add
this.getRoutes()
option
Download Details:
Author: boussadjra
Live Demo: https://codesandbox.io/s/vue-3-router-tree-demo-wzxr1?file=/src/App.vue
Download Link: https://github.com/boussadjra/vue3-router-tree/archive/main.zip
Official Website: https://github.com/boussadjra/vue3-router-tree
Install & Download:
# NPM
$ npm i vue3-router-tree --save