Files
workspace/code/g3soft-libs/docs/examples/button/event.vue
T
2026-10-08 22:38:34 +08:00

23 lines
794 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
// click 回传原生 MouseEvent:可以读修饰键,也可以阻止默认行为
import { ref } from 'vue'
import { G3Button, G3Space } from '@g3soft/ui'
const last = ref('暂无')
function handleClick(event: MouseEvent) {
const withKey = event.ctrlKey || event.metaKey ? '(按住了 Ctrl/Cmd)' : ''
last.value = `点击${withKey} @ ${event.clientX},${event.clientY}`
}
</script>
<template>
<G3Space direction="vertical" :size="12" style="display: flex">
<G3Space :size="8">
<G3Button @click="handleClick">点我(可按住 Ctrl)</G3Button>
<G3Button type="outline" @click="handleClick">也是点我</G3Button>
</G3Space>
<span style="color: #6b7280; font-size: 13px">最近一次:{{ last }}</span>
</G3Space>
</template>