Skip to content

Commit 32caf5d

Browse files
author
Michaela Robosova
committed
Update README
1 parent dd602fb commit 32caf5d

File tree

1 file changed

+107
-12
lines changed

1 file changed

+107
-12
lines changed

README.md

Lines changed: 107 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,142 @@
22

33
> Vue.js 2 tree navigation with vue-router support
44
5-
For more information see [documentation/demo](https://vue-tree-navigation.misrob.cz)
5+
For more detailed information see [documentation/demo](https://vue-tree-navigation.misrob.cz)
66

77
## Features
88

99
- unlimited number of levels
1010
- optional [vue-router](https://router.vuejs.org/en/) support (v2.0.0 or higher)
11-
- a possibility to define a default open level
11+
- generate navigation items automatically from _vue-router_ routes or define them manually
12+
- define a default open level
1213
- auto-open a level when a corresponding URL visited
1314
- focused on core functionality, only necessary styles included
1415
- elements are provided with meaningful classes to make customizations comfortable (for example `NavigationItem--active`, `NavigationLevel--level-1`, `NavigationLevel--closed`)
15-
- external URLs support
1616

1717
## Example
1818

19+
### 1. Navigation items generated from _vue-router_ routes
20+
21+
Let's suppose you use _vue-router_ with the following routes definition
22+
23+
```javascript
24+
const routes = [
25+
{
26+
name: 'Home',
27+
path: '/',
28+
},
29+
{
30+
name: 'Running',
31+
path: '/running',
32+
children: [
33+
{
34+
name: 'Barefoot',
35+
path: 'barefoot',
36+
},
37+
],
38+
},
39+
{
40+
name: 'Yoga',
41+
path: '/yoga',
42+
children: [
43+
{
44+
name: 'Mats',
45+
path: 'mats',
46+
},
47+
{
48+
name: 'Tops',
49+
path: 'tops',
50+
},
51+
],
52+
},
53+
{
54+
name: 'About',
55+
path: '/about',
56+
children: [
57+
{
58+
name: 'Career',
59+
path: 'career',
60+
children: [
61+
{
62+
name: 'Design',
63+
path: 'design',
64+
},
65+
],
66+
},
67+
],
68+
},
69+
];
70+
```
71+
72+
Then simply include _vue-tree-navigation_
73+
1974
```html
2075
<template>
21-
<vue-tree-navigation :items="items" :defaultOpenLevel="1" />
76+
<vue-tree-navigation />
77+
</template>
78+
```
79+
80+
and it will generate the following menu:
81+
82+
```
83+
- Home // --> /
84+
- Running // --> /running
85+
- Barefoot // --> /running/barefoot
86+
- Yoga // --> /yoga
87+
- Mats // --> /yoga/mats
88+
- Tops // --> /yoga/tops
89+
- About // --> /about
90+
- Career // --> /about/career
91+
- Design // --> /about/career/design
92+
```
93+
94+
Do not forget to use named routes since _vue-tree-navigation_ uses `name` field to label navigation items.
95+
96+
### 2. Menu items defined manually
97+
98+
The following configuration
99+
100+
```html
101+
<template>
102+
<vue-tree-navigation :items="items" />
22103
</template>
23104

24105
<script>
25106
export default {
26107
data() {
27108
return {
28109
items: [
29-
{ name: 'Products', children: [ // category label
30-
{ name: 'Shoes', path: 'shoes' } // /shoes
110+
{ name: 'Products', children: [
111+
{ name: 'Shoes', path: 'shoes' }
31112
]},
32-
{ name: 'About', path: 'about', children: [ // /about
33-
{ name: 'Contact', path: 'contact', children: [ // /about/contact
34-
{ name: 'E-mail', element: 'email' }, // /about/contact#email
35-
{ name: 'Phone', element: 'phone' } // /about/contact#phone
113+
{ name: 'About', path: 'about', children: [
114+
{ name: 'Contact', path: 'contact', children: [
115+
{ name: 'E-mail', element: 'email' },
116+
{ name: 'Phone', element: 'phone' }
36117
]},
37118
]},
38-
{ name: 'Github', external: 'https://github.com' }, // https://github.com
119+
{ name: 'Github', external: 'https://github.com' },
39120
],
40121
};
41122
},
42123
};
43124
</script>
44125
```
45126

127+
will generate
128+
129+
```
130+
- Products // category label
131+
- Shoes // --> /shoes
132+
- About // --> /about
133+
- Contact // --> /about/contact
134+
- E-mail // --> /about/contact#email
135+
- Phone // --> /about/contact#phone
136+
- Github // --> https://github.com
137+
```
138+
139+
For more examples see [documentation/demo](https://vue-tree-navigation.misrob.cz)
140+
46141
## Installation
47142

48143
### NPM
@@ -62,7 +157,7 @@ Vue.use(VueTreeNavigation);
62157
### Include with a script tag
63158

64159
```html
65-
<script src="https://unpkg.com/vue-tree-navigation@3.0.0/dist/vue-tree-navigation.js"></script>
160+
<script src="https://unpkg.com/vue-tree-navigation@4.0.0/dist/vue-tree-navigation.js"></script>
66161

67162
<script>
68163
Vue.use(VueTreeNavigation)

0 commit comments

Comments
 (0)