fix: type error

This commit is contained in:
Rewrite0
2023-06-14 23:10:53 +08:00
parent 2585ab2686
commit 1e0158636b
2 changed files with 13 additions and 5 deletions

View File

@@ -8,13 +8,13 @@ const props = withDefaults(
}
);
const abLabel = () => {
function abLabel() {
if (typeof props.label === 'function') {
return props.label();
} else {
return props.label;
}
};
}
</script>
<template>

View File

@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue';
import { AddOne, More, International } from '@icon-park/vue-next';
import { AddOne, International, More } from '@icon-park/vue-next';
withDefaults(
defineProps<{
@@ -8,7 +8,7 @@ withDefaults(
items: {
id: number;
icon: any;
label: string;
label: string | (() => string);
handle?: () => void | Promise<void>;
}[];
}>(),
@@ -21,6 +21,14 @@ defineEmits<{
(e: 'changeLang'): void;
(e: 'clickAdd'): void;
}>();
function abLabel(label: string | (() => string)) {
if (typeof label === 'function') {
return label();
} else {
return label;
}
}
</script>
<template>
@@ -76,7 +84,7 @@ defineEmits<{
:class="[active ? 'text-white bg-theme-row' : 'text-black']"
@click="() => i.handle && i.handle()"
>
<div text-main>{{ i.label }}</div>
<div text-main>{{ abLabel(i.label) }}</div>
<div
class="group-hover:text-white"