You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用MUI v6.1.1导航栏(App bar)时出现Uncaught TypeError报错求助

使用MUI v6.1.1导航栏(App bar)时出现Uncaught TypeError报错求助

我最近在尝试用MUI(Material UI)的导航栏组件,就是那种带主搜索框的样式,用的版本是v6.1.1。奇怪的是,在代码沙箱里测试的时候一切正常,但把组件放到自己项目里就直接报错了,错误提示是:
Uncaught TypeError: number 0 is not iterable (cannot read property Symbol(Symbol.iterator))

我的代码片段:

export default function NavBar() {
  const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); // 报错指向这一行
  const [mobileMoreAnchorEl, setMobileMoreAnchorEl] = React.useState<null | HTMLElement>(null);

  const isMenuOpen = Boolean(anchorEl);
  const isMobileMenuOpen = Boolean(mobileMoreAnchorEl);

完整代码对应MUI官方带主搜索框的导航栏示例结构。

详细错误信息:

(原提问未补充完整详细错误内容)

有没有大佬遇到过类似的问题?麻烦帮忙排查下问题出在哪呀😭

备注:内容来源于stack exchange,提问作者Lakshay Rohilla

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 14:58:12