liveh5-nuxt/app/components/x-button/index.vue
xingyy b876aac28a fix(components): 修复手机端点击事件导致按钮状态异常
- 在 x-button 组件中添加 event.stopPropagation() 以防止事件冒泡- 更新 SideButton 组件中的事件处理方式,确保点击事件正确触发
2025-01-23 19:41:09 +08:00

28 lines
539 B
Vue

<script setup>
import { ref } from "vue";
const isButtonActive = ref(false);
const handleButtonPress = (event) => {
event.stopPropagation();
isButtonActive.value = true;
};
const handleButtonRelease = (event) => {
event.stopPropagation();
isButtonActive.value = false;
};
</script>
<template>
<div
:class="[
'transition-all duration-200',
isButtonActive ? 'scale-95' : ''
]"
@touchstart.stop="handleButtonPress"
@touchend.stop="handleButtonRelease"
>
<slot></slot>
</div>
</template>