ant-design-vue
ant-design-vue copied to clipboard
使用循环生成a-menu-item选择默认的key不生效
- [ ] I have searched the issues of this repository and believe that this is not a duplicate.
Version
undefined
Environment
Vue3
Reproduction link
https://www.antdv.com/components/layout-cn
Steps to reproduce
What is expected?
期望const selectedKeys = ref(['1']);时会被默认选中
What is actually happening?
没有选中任何
id改成 ‘1’ 试试
<div style="float: right;padding-right: 20px">
<a-avatar :size="32">
<template #icon>
<UserOutlined/>
</template>
</a-avatar>
</div>
</a-layout-header>
<a-layout-content style="margin: 0 16px">
<!-- <a-breadcrumb style="margin: 16px 0">-->
<!-- <a-breadcrumb-item>主页</a-breadcrumb-item>-->
<!-- <a-breadcrumb-item>Bill</a-breadcrumb-item>-->
<!-- <a-breadcrumb-item>aaa</a-breadcrumb-item>-->
<!-- </a-breadcrumb>-->
<a-breadcrumb style="margin: 16px 0">
<a-breadcrumb-item>主页</a-breadcrumb-item>
<template v-for="item in menu_list" :key="item.id">
<a-breadcrumb-item v-if="item.id === selectedKeys[0]">{{ item.title }}</a-breadcrumb-item>
</template>
</a-breadcrumb>
<div :style="{ padding: '24px', background: '#fff', minHeight: '360px' }">
<router-view></router-view>
</div>
</a-layout-content>
<a-layout-footer style="text-align: center">
Ant Design ©2024 Created by Ant UED
</a-layout-footer>
</a-layout>
这是我的脚本麻烦帮忙看看
@linzehai0801 我的意思是,你的id是数字,但是selectKeys里的是字符串,这两个要保持统一,把你menu_list里的id:1改成id: '1'这样
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days