forked from vueComponent/ant-design-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.vue
56 lines (49 loc) · 1.29 KB
/
event.vue
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
<docs>
---
order: 4
title:
zh-CN: 触发事件
en-US: Click event
---
## zh-CN
点击菜单项后会触发事件,用户可以通过相应的菜单项 key 进行不同的操作。
## en-US
An event will be triggered when you click menu items, in which you can make different operations according to item's key.
</docs>
<template>
<a-dropdown @visible-change="handleVisibleChange">
<a class="ant-dropdown-link" @click.prevent>
Hover me, Click menu item
<DownOutlined />
</a>
<template #overlay>
<a-menu @click="onClick">
<a-menu-item key="1">1st menu item</a-menu-item>
<a-menu-item key="2">2nd menu item</a-menu-item>
<a-menu-item key="3">3rd menu item</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { DownOutlined } from '@ant-design/icons-vue';
import type { MenuProps } from 'ant-design-vue';
export default defineComponent({
components: {
DownOutlined,
},
setup() {
const onClick: MenuProps['onClick'] = ({ key }) => {
console.log(`Click on item ${key}`);
};
const handleVisibleChange = (value: boolean) => {
console.log('visible', value);
};
return {
onClick,
handleVisibleChange,
};
},
});
</script>