Vue simple menu
Vue component for fast create simple menu block
I will be glad to correct the inaccuracy of the my English
Simple menu component with a set of basic functionality, which is enought in 80% of cases
For whom?
Simple and easy menu with a set of basic functionality, which is enought in 80% of cases:
- Menu items with direct link (href="/url.html")
- Compatibility with vue-router
- Menu items can be toggle expand
- Menu items with infinity nesting
- Stylize as you want (you can select default or make and require own style)
Installation and usage
ES6 via npm
Usage
For example, we have app container, and menu component inside
For building menu, you need pass to raw-menu-data
data of menu, must be of a certain format
Params
Name | Type | Description |
---|---|---|
id | string | ID for item. It is link to itself id key (figure 1) ID format as you want |
name | string | Name or title for menu item element (figure 2) |
uri | string | Add link to item element (figure 3) |
list | array: object | Add children elements to item (figure 4) The structure of nesting objects repeats the main parent |
For example file rawMenuData.js
And add imported menu component to Vue app. Menu data pass as component
Component as global in browser
Pass to your html page scripts below
Usage
Add element for our application with menu
And use in you scripts some as:
Usage with Vue Router
You can use simple menu with vue router links
Just add value vueRouter: true
in rawMenuData, and items with this value will be work as vue-router link
Is implied, the vue router is already connected in your app script
Example below
Done!
Stylize
You can use default styles for menu. Just require sass or css file to your project from styles folder in src. You should setup webpack config for processing styles (for example css-loader)
Example
Or pass default style from CDN
Example