@@ -33,7 +33,11 @@ Or you can include it through the browser at the bottom of your page along with
33
33
``` html
34
34
<script src =" https://unpkg.com/vue-simple-context-menu/dist/vue-simple-context-menu.min.js" ></script >
35
35
36
- <link rel =" stylesheet" type =" text/css" href =" https://unpkg.com/vue-simple-context-menu/dist/vue-simple-context-menu.css" >
36
+ <link
37
+ rel =" stylesheet"
38
+ type =" text/css"
39
+ href =" https://unpkg.com/vue-simple-context-menu/dist/vue-simple-context-menu.css"
40
+ />
37
41
```
38
42
39
43
### About
@@ -44,44 +48,49 @@ A nice feature that comes baked in is the menu placement after a click - it sits
44
48
45
49
### Usage Example
46
50
47
- ``` html
48
- <!-- css import for when you want to import the component css into your css file/files -->
49
- @import '/path/to/node_modules/vue-simple-context-menu.css';
51
+ ``` css
52
+ /* css import for when you want to import the component css into your css file/files */
53
+ @import " /path/to/node_modules/vue-simple-context-menu.css" ;
54
+ ```
50
55
51
- <!-- css import for when you're importing the css directly in your js -->
52
- import 'vue-simple-context-menu/dist/vue-simple-context-menu.css'
56
+ ``` js
57
+ // css import for when you're importing the css directly in your js
58
+ import " vue-simple-context-menu/dist/vue-simple-context-menu.css" ;
59
+ import VueSimpleContextMenu from " vue-simple-context-menu" ;
53
60
54
- import VueSimpleContextMenu from 'vue-simple-context-menu'
55
- Vue.component('vue-simple-context-menu', VueSimpleContextMenu)
61
+ Vue .component (" vue-simple-context-menu" , VueSimpleContextMenu);
56
62
```
57
63
58
64
``` html
59
65
<!-- This is a basic use case where you have an array of items that you want
60
66
to allow to be clicked. In this case, `items` is an array of objects.
61
67
Each item has a click event that ties to a function. See the demo for a full example (with multiple menus as well). -->
62
-
63
68
<div class =" item-wrapper" >
64
- <div v-for =" item in items" @click.prevent.stop =" handleClick($event, item)" class =" item-wrapper__item" >
69
+ <div
70
+ v-for =" item in items"
71
+ @click.prevent.stop =" handleClick($event, item)"
72
+ class =" item-wrapper__item"
73
+ >
65
74
{{item.name}}
66
75
</div >
67
76
</div >
68
77
69
78
<!-- Make sure you add the `ref` attribute, as that is what gives you the ability
70
79
to open the menu. -->
71
-
72
80
<vue-simple-context-menu
73
81
:elementId =" 'myUniqueId'"
74
82
:options =" options"
75
83
:ref =" 'vueSimpleContextMenu'"
76
84
@option-clicked =" optionClicked"
77
85
/>
86
+ ```
78
87
79
- <!-- The click-handler function -->
88
+ ``` js
80
89
handleClick (event , item ) {
81
90
this .$refs .vueSimpleContextMenu .showMenu (event , item)
82
91
}
83
92
84
- <!-- And for capturing the event -->
93
+
85
94
optionClicked (event ) {
86
95
window .alert (JSON .stringify (event ))
87
96
}
@@ -93,26 +102,27 @@ Note - make sure to use `@click.prevent.stop` (or `@contextmenu.prevent.stop` fo
93
102
94
103
### Props
95
104
96
- | prop | type | description | required |
97
- | ---------| ------- | --------------------------------| ---|
98
- | elementId | String | Unique String that acts as the id of your menu. | Yes |
99
- | options | Array | Array of menu options to show. Component will use the ` name ` parameter as the label. | Yes |
100
- | options.name | Array | Label for the option. | Yes |
101
- | options.class | String | A custom class that will be applied to the option. | No |
102
- | options.type | String | Only one possible value at the moment - ` divider ` . Pass this to set the object as a divider. | No |
103
- | ref | String | Unique String that allows you to show the menu on command. | Yes |
105
+ | prop | type | description | required |
106
+ | --------------- | ------ | -------------------------------------------------------------------------------------------- | -------- |
107
+ | ` elementId ` | String | Unique String that acts as the id of your menu. | Yes |
108
+ | ` options ` | Array | Array of menu options to show. Component will use the ` name ` parameter as the label. | Yes |
109
+ | ` options.name ` | Array | Label for the option. | Yes |
110
+ | ` options.class ` | String | A custom class that will be applied to the option. | No |
111
+ | ` options.type ` | String | Only one possible value at the moment - ` divider ` . Pass this to set the object as a divider. | No |
112
+ | ` ref ` | String | Unique String that allows you to show the menu on command. | Yes |
104
113
105
114
### Methods
106
115
107
- | method | parameters | description |
108
- | ---------| -------| --------------------------------|
109
- | showMenu | event (MouseEvent), item (Object) | Used to show the menu. Make sure to pass a MouseEvent and an Object. |
116
+ | method | parameters | description |
117
+ | ---------- | --------------------------------- | -------------------------------------------------------------------- |
118
+ | ` showMenu ` | event (MouseEvent), item (Object) | Used to show the menu. Make sure to pass a MouseEvent and an Object. |
110
119
111
120
### Events
112
121
113
- | event | value | description |
114
- | ---------| -------| --------------------------------|
115
- | option-clicked | Object | When a menu item is clicked the component will emit an event with a value containing the clicked item and the menu option that was clicked. Register for this event to capture the selection result. |
122
+ | event | value | description |
123
+ | ---------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
124
+ | ` option-clicked ` | Object | When a menu item is clicked the component will emit an event with a value containing the clicked item and the menu option that was clicked. Register for this event to capture the selection result. |
125
+ | ` menu-closed ` | | Emitted when the menu is closed |
116
126
117
127
### SASS Structure
118
128
@@ -126,13 +136,14 @@ Note - make sure to use `@click.prevent.stop` (or `@contextmenu.prevent.stop` fo
126
136
}
127
137
}
128
138
129
- & __divider {}
139
+ & __divider {
140
+ }
130
141
}
131
142
```
132
143
133
144
### Development
134
145
135
- ``` bash
146
+ ``` bash
136
147
# install dependencies
137
148
npm install
138
149
0 commit comments