Browse Source

fix(架构): 修复右上角下拉警告报错的问题

shizhongming 2 years ago
parent
commit
869b90aeb1
  1. 13
      src/layouts/default/header/components/user-dropdown/DropMenuItem.vue

13
src/layouts/default/header/components/user-dropdown/DropMenuItem.vue

@ -1,14 +1,14 @@
<template>
<Menu.Item :key="itemKey">
<span class="flex items-center">
<Icon :icon="icon" class="mr-1" />
<span>{{ text }}</span>
<Icon :icon="props.icon" class="mr-1" />
<span>{{ props.text }}</span>
</span>
</Menu.Item>
</template>
<script lang="ts" setup>
import { Menu } from 'ant-design-vue';
import { computed, getCurrentInstance } from 'vue';
import { computed, getCurrentInstance, useAttrs } from 'vue';
import Icon from '@/components/Icon/Icon.vue';
import { propTypes } from '@/utils/propTypes';
@ -16,11 +16,14 @@
const props = defineProps({
// eslint-disable-next-line
key: propTypes.string,
text: propTypes.string,
icon: propTypes.string,
});
const attrs = useAttrs();
const instance = getCurrentInstance();
const itemKey = computed(() => props.key || instance?.vnode?.props?.key);
const itemKey = computed(
() => (attrs.key || instance?.vnode?.props?.key) as string | number | undefined,
);
</script>

Loading…
Cancel
Save