提问人:cambraca 提问时间:6/10/2021 更新时间:11/4/2022 访问量:3276
了解我的自定义 Svelte 组件中是否有单击事件处理程序
Know if there's a click event handler in my custom Svelte component
问:
有没有办法知道我的自定义组件上是否设置了点击处理程序?我想向它添加一个CSS类来添加样式,但前提是点击时会发生一些事情。cursor: pointer;
为了说明这一点,下面可能是自定义组件:
<script>
$: magic = ? // this is what I'm after
</script>
<div on:click
class:pointer={magic}
>
I might be clickable!
</div>
<style>
.pointer {
cursor: pointer;
}
</style>
答:
评论