ant-design-vue/components/anchor/demo/onClick.vue

45 lines
979 B
Vue

<docs>
---
order: 2
title:
zh-CN: 自定义 click 事件
en-US: Customize the click event
---
## zh-CN
点击锚点不记录历史
## en-US
Clicking on an anchor does not record history.
</docs>
<template>
<a-anchor :affix="false" @click="handleClick">
<a-anchor-link href="#components-anchor-demo-basic" title="Basic demo" />
<a-anchor-link href="#components-anchor-demo-static" title="Static demo" />
<a-anchor-link href="#API" title="API">
<a-anchor-link href="#Anchor-Props" title="Anchor Props" />
<a-anchor-link href="#Link-Props" title="Link Props" />
</a-anchor-link>
</a-anchor>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import type { AnchorProps } from 'ant-design-vue';
export default defineComponent({
setup() {
const handleClick: AnchorProps['onClick'] = (e, link) => {
e.preventDefault();
console.log(link);
};
return {
handleClick,
};
},
});
</script>