File tree Expand file tree Collapse file tree 5 files changed +94
-42
lines changed Expand file tree Collapse file tree 5 files changed +94
-42
lines changed Original file line number Diff line number Diff line change 66## Usage
77
88``` HTML
9- <ContextMenu :text =" hello" ></ContextMenu >
9+ <ContextMenu ref =" contextMenu" :menu-items =" menuItems" />
10+
11+ <div class =" context-menu-trigger"
12+ @click.right.prevent =" $refs.contextMenu.open($event)" >
13+ Right Click Me!
14+ </div >
1015```
1116
1217``` javascript
13- import { ContextMenu } from ' vue-context-menu-popup'
18+ import ContextMenu from ' vue-context-menu-popup'
1419
1520export default {
21+ data () {
22+ return {
23+ menuItems: [
24+ {
25+ label: ' First Menu Item' ,
26+ },
27+ {
28+ label: ' Disabled Menu Item' ,
29+ disabled: true ,
30+ },
31+ {
32+ label: ' I have children' ,
33+ children: [
34+ {
35+ label: ' Child Item 1' ,
36+ },
37+ {
38+ label: ' I also have children' ,
39+ children: [
40+ {
41+ label: ' Child Item 2' ,
42+ },
43+ ],
44+ },
45+ ],
46+ },
47+ ]
48+ }
49+ },
1650 components: {
1751 ContextMenu
1852 }
@@ -23,11 +57,15 @@ export default {
2357
2458### context-menu
2559
26- eslint-disable prefer-destructuring
60+ A simple context menu component
61+
62+ ``` html
63+ <ContextMenu :menu-items =" [....]" />
64+ ```
2765
2866#### props
2967
30- - ` menu-items ` *** Array*** (* optional * )
68+ - ` menu-items ` *** Array*** (* required * )
3169
3270#### data
3371
@@ -45,6 +83,8 @@ eslint-disable prefer-destructuring
4583
4684- ` open(position) `
4785
86+ Accepts an Object with an ` x, y ` position or an instance of Event
87+
4888## Installation
4989
5090```
Original file line number Diff line number Diff line change 1212</template >
1313
1414<script >
15- import ContextMenu from ' @/components/ContextMenu.vue' ;
15+ import ContextMenu from ' @/components/ContextMenu.vue' ;
1616
17- export default {
18- name: ' app' ,
19- data () {
20- return {
21- menuItems: [
22- {
23- ' label' : ' First Menu Item'
24- },
25- {
26- ' label' : ' Disabled Menu Item' ,
27- ' disabled' : true
28- },
29- {
30- ' label' : ' I have children' ,
31- ' children' : [
32- {
33- ' label' : ' Child Item 1'
34- },
35- {
36- ' label' : ' I also have children' ,
37- ' children' : [
38- {
39- ' label' : ' Child Item 2'
40- }
41- ]
42- }
43- ]
44- }
45- ],
46- consoleMessage: [],
47- };
48- },
49- components: {
50- ContextMenu,
51- },
52- };
17+ export default {
18+ name: ' app' ,
19+ data () {
20+ return {
21+ menuItems: [
22+ {
23+ label: ' First Menu Item' ,
24+ },
25+ {
26+ label: ' Disabled Menu Item' ,
27+ disabled: true ,
28+ },
29+ {
30+ label: ' I have children' ,
31+ children: [
32+ {
33+ label: ' Child Item 1' ,
34+ },
35+ {
36+ label: ' I also have children' ,
37+ children: [
38+ {
39+ label: ' Child Item 2' ,
40+ },
41+ ],
42+ },
43+ ],
44+ },
45+ ],
46+ consoleMessage: [],
47+ };
48+ },
49+ components: {
50+ ContextMenu,
51+ },
52+ };
5353 </script >
5454
5555<style lang="scss">
Original file line number Diff line number Diff line change 1717import ContextMenuItem from ' ./ContextMenuItem.vue' ;
1818import ClickOutside from ' ../directives/ClickOutside' ;
1919
20+ /**
21+ * A simple context menu component
22+ *
23+ * ```html
24+ * <ContextMenu :menu-items="[....]"/>
25+ * ```
26+ */
2027export default {
2128 props: {
2229 menuItems: {
2330 type: Array ,
31+ required: true ,
2432 },
2533 },
2634
@@ -39,6 +47,9 @@ export default {
3947 this .visible = false ;
4048 },
4149
50+ /**
51+ * Accepts an Object with an `x, y` position or an instance of Event
52+ */
4253 open (position ) {
4354 let x = 0 ;
4455 let y = 0 ;
Original file line number Diff line number Diff line change 1+ /* eslint-disable no-param-reassign */
12export default {
23 bind ( el , binding , vnode ) {
34 el . clickOutsideEvent = ( event ) => {
Original file line number Diff line number Diff line change 11import ContextMenu from './components/ContextMenu.vue' ;
22
3- export { ContextMenu } ;
3+ export default ContextMenu ;
You can’t perform that action at this time.
0 commit comments