#8219·naive-ui

n-menu控件的icon类型强制要求function类型

Author: Aries9310Created Sep 18, 2026Updated Sep 18, 2026
Labelsuntriaged
Image

描述错误

对于n-menu控件而言,即使是使用render-icon属性自己渲染图标,框架依然会检查提供的options的icon字段类型,我认为这是不合理的,因为有可能我提供的options里的icon字段就是一个单纯的链接(String类型),然后通过render-icon渲染,但是目前这样做的话会导致warning

复现步骤

<n-menu :collapsed="collapsed" :collapsed-width="48" :collapsed-icon-size="24" key-field="id" children-field="children" :options="uiPermissionList" :render-icon="renderMenuIcon" :render-label="renderMenuLabel" @update:value="handleUpdateValue" />

const uiPermissionList = [ id: 'xxx', name: 'xxx', icon: 'xxx', children: [ ... ] ]

const renderMenuIcon = (row) => { return dosomething(row.icon) }

最小复现链接

系统信息

bash
- naive-ui:2.45.3
- vue:3.5.42
- 构建:Vite + `<script setup>`,普通 Vue 3 应用(未启用 Vapor 模式)

使用的包管理器

pnpm

验证