forked from CyberNika/v-contextmenu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDynamic.vue
More file actions
64 lines (58 loc) · 1.21 KB
/
Dynamic.vue
File metadata and controls
64 lines (58 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<template>
<div class="example">
<v-contextmenu ref="contextmenu" :theme="theme">
<v-contextmenu-item
@click="handleClick"
v-for="item of list"
:key="item.id">
{{ item.label }}
</v-contextmenu-item>
</v-contextmenu>
<div :class="['box', theme]" v-for="item of list" :key="item.id" v-contextmenu:contextmenu>
右键点击此区域(点击菜单动态改变)
</div>
</div>
</template>
<script>
export default {
name: 'Simple',
props: {
theme: String,
},
data () {
return {
list: [{
id: 0,
label: 'Menu 0',
onClick: this.handleClick,
}, {
id: 1,
label: 'Menu 1',
onClick: this.handleClick,
}, {
id: 2,
label: 'Menu 2',
onClick: this.handleClick,
}],
}
},
methods: {
handleClick (vm, event) {
if (this.list.length === 3) {
this.list.push({
id: 3,
label: 'Menu 3',
onClick: this.handleClick,
})
} else {
this.list.pop()
}
},
},
}
</script>
<style scoped>
.box {
width: 100%;
}
</style>