Cannot read properties of undefined (reading ‘push‘)

TypeError: Cannot read properties of undefined (reading 'push')

今天在写react的后台管理系统中遇到了这个问题,目的是点击不同的菜单列表展示不同的路由,出现错误的原代码如下:

 const Admin = ({history}) => {
    const [collapsed, setCollapsed] = useState(false);
  
    const dispatch = useDispatch()
    const loginOutConfirm = () => {
        confirm({
          title: '真的要退出吗?',
          icon: <ExclamationCircleOutlined />,
          content: '本网站不会保存你的操作,真的要退出吗?',
      
          onOk() {
           dispatch(loginOutAction())
          },
      
          onCancel() {
            console.log('Cancel');
          },
        });
      };
    
  return (
    <AdminContainer>
      <Layout style={
  {height:'100%' }}>
      <Sider trigger={null} collapsible collapsed={collapsed}>
        <div  >
            <img className="logo"  src="https://t7.baidu.com/it/u=3571871208,2635260997&fm=193&f=GIF" alt="" />
        </div>
        <Menu
          theme="dark"
          mode="inline"
          defaultSelectedKeys={[]}
          defaultOpenKeys={['2']}
          onClick={({key}) =>{
           history.push(key)
          console.log(key)
          }}
          items={[
            {
              key: '/admin/main',
              icon: <UserOutlined />,
              label: '后台首页',
            },
            {
              key: '2',
              icon: <VideoCameraOutlined /&g
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
根据引用\[1\]中的错误信息,"TypeError: Cannot read properties of undefined (reading 'push')",这个错误是在Vue的渲染过程中发生的,具体出错的地方是在TbBDevForm组件的v-on事件处理程序中。根据引用\[2\]中的问题排查,可能是在点击确定按钮时,对应的方法中的数组未定义导致的。另外,引用\[3\]中的代码展示了使用withRouter将组件暴露出去,并使用编程式导航实现路由跳转的方法。根据提供的信息,可能需要检查TbBDevForm组件中的数组定义是否正确,并确保在点击确定按钮时,该数组已经被正确定义。 #### 引用[.reference_title] - *1* *2* [Cannot read properties of undefined (readingpush‘) 问题](https://blog.csdn.net/weixin_43664448/article/details/121830467)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [index.js:25 Uncaught TypeError: Cannot read properties of undefined (readingpush‘)](https://blog.csdn.net/weixin_45224165/article/details/128065268)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Zwq8023520

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值