「已解决」umi 路由配置 icon 图标报错问题

问题

当umi的路由配置中带有icon时就会白屏报错
比如这样可以正常渲染
(前面三个路由配置也是一开始加图标就报错,但是后面不知道怎么搞的不报错了)

export const route = [
  {
    path: '/',
    redirect: '/home',
  },
  {
    name: '首页',
    icon: 'HomeOutlined',
    path: '/home',
    component: './Home',
  },
  {
    name: '权限演示',
    icon: 'ControlOutlined',
    path: '/access',
    component: './Access',
  },
  {
    name: ' CRUD 示例',
    icon: 'FormOutlined',
    path: '/table',
    component: './Table',
  },
  {
    name: 'basic-list',
    // icon: 'TableOutlined',
    path: '/basicList',
    component: './BasicList',
  },
];

在这里插入图片描述
把注释去掉就白屏
在这里插入图片描述

报错

  • index.js:1 The above error occurred in the component:
  • index.js:1 Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
  • mf-dep____vendor.8579e6bb.js:284446 Uncaught TypeError: Cannot read properties of null (reading ‘useContext’)

解决

在运行的时候实时修改路由的 icon 不会生效
重新启动就可以了

思考

似乎使用 Ant-Icon 时都有这个问题!

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

zoe_ya

如果你成功申请,可以打赏杯奶茶

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

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

打赏作者

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

抵扣说明:

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

余额充值