Browse Source

【issues/6855】组件使用key作props报警告,改为itemKey

pull/7021/head
JEECG 4 months ago
parent
commit
4753a74456
  1. 7
      jeecgboot-vue3/src/layouts/default/header/components/user-dropdown/DropMenuItem.vue
  2. 14
      jeecgboot-vue3/src/layouts/default/header/components/user-dropdown/index.vue

7
jeecgboot-vue3/src/layouts/default/header/components/user-dropdown/DropMenuItem.vue

@ -18,13 +18,16 @@
name: 'DropdownMenuItem', name: 'DropdownMenuItem',
components: { MenuItem: Menu.Item, Icon }, components: { MenuItem: Menu.Item, Icon },
props: { props: {
key: propTypes.string, // issues/6855
itemKey: propTypes.string,
text: propTypes.string, text: propTypes.string,
icon: propTypes.string, icon: propTypes.string,
}, },
setup(props) { setup(props) {
const instance = getCurrentInstance(); const instance = getCurrentInstance();
const itemKey = computed(() => props.key || instance?.vnode?.props?.key); // update-begin--author:liaozhiyang---date:20240717---forissues/6855使keypropsitemKey
const itemKey = computed(() => props.itemKey || instance?.vnode?.props?.itemKey);
// update-end--author:liaozhiyang---date:20240717---forissues/6855使keypropsitemKey
return { itemKey }; return { itemKey };
}, },
}); });

14
jeecgboot-vue3/src/layouts/default/header/components/user-dropdown/index.vue

@ -11,19 +11,19 @@
<template #overlay> <template #overlay>
<Menu @click="handleMenuClick"> <Menu @click="handleMenuClick">
<MenuItem key="doc" :text="t('layout.header.dropdownItemDoc')" icon="ion:document-text-outline" v-if="getShowDoc" /> <MenuItem itemKey="doc" :text="t('layout.header.dropdownItemDoc')" icon="ion:document-text-outline" v-if="getShowDoc" />
<MenuDivider v-if="getShowDoc" /> <MenuDivider v-if="getShowDoc" />
<MenuItem key="account" :text="t('layout.header.dropdownItemSwitchAccount')" icon="ant-design:setting-outlined" /> <MenuItem itemKey="account" :text="t('layout.header.dropdownItemSwitchAccount')" icon="ant-design:setting-outlined" />
<MenuItem key="password" :text="t('layout.header.dropdownItemSwitchPassword')" icon="ant-design:edit-outlined" /> <MenuItem itemKey="password" :text="t('layout.header.dropdownItemSwitchPassword')" icon="ant-design:edit-outlined" />
<MenuItem key="depart" :text="t('layout.header.dropdownItemSwitchDepart')" icon="ant-design:cluster-outlined" /> <MenuItem itemKey="depart" :text="t('layout.header.dropdownItemSwitchDepart')" icon="ant-design:cluster-outlined" />
<MenuItem key="cache" :text="t('layout.header.dropdownItemRefreshCache')" icon="ion:sync-outline" /> <MenuItem itemKey="cache" :text="t('layout.header.dropdownItemRefreshCache')" icon="ion:sync-outline" />
<!-- <MenuItem <!-- <MenuItem
v-if="getUseLockPage" v-if="getUseLockPage"
key="lock" itemKey="lock"
:text="t('layout.header.tooltipLock')" :text="t('layout.header.tooltipLock')"
icon="ion:lock-closed-outline" icon="ion:lock-closed-outline"
/>--> />-->
<MenuItem key="logout" :text="t('layout.header.dropdownItemLoginOut')" icon="ion:power-outline" /> <MenuItem itemKey="logout" :text="t('layout.header.dropdownItemLoginOut')" icon="ion:power-outline" />
</Menu> </Menu>
</template> </template>
</Dropdown> </Dropdown>

Loading…
Cancel
Save