feat: FontAwesomeIcon click emit

This commit is contained in:
h_mo 2022-10-02 19:28:01 +08:00
parent e587fb5be6
commit f8866ece2a
2 changed files with 11 additions and 3 deletions

View File

@ -12,6 +12,10 @@
import { FontAwesomeIconProps } from '@/components/FontAwesomeIcon/props';
const props = defineProps(FontAwesomeIconProps);
const emit = defineEmits<{
(e: 'click'): void;
}>();
const singleBeat = props.beat && !props.fade;
const singleFade = !props.beat && props.fade;
const BeatFade = props.beat && props.fade;
@ -108,15 +112,19 @@
color: props.color,
'font-size': props.size ? `${props.size}rpx` : false,
});
const onClick = () => {
emit('click');
};
</script>
<template>
<template v-if="props.stack">
<view class="icon-wrap" :class="wrapClassObject" :style="wrapStyleObject">
<view @click="onClick" class="icon-wrap" :class="wrapClassObject" :style="wrapStyleObject">
<slot :stack="props.stack"></slot>
</view>
</template>
<template v-else>
<view class="icon-wrap" :class="wrapClassObject" :style="wrapStyleObject">
<view @click="onClick" class="icon-wrap" :class="wrapClassObject" :style="wrapStyleObject">
<text class="icon" :style="iconStyleObject" :class="iconClassObject" />
</view>
</template>

View File

@ -7,7 +7,7 @@ export const FontAwesomeIconProps = {
name: {
type: String,
default: 'default',
required: true,
// required: true,
},
/** icon
* css, 使css