ctor is not a function

 这是我今天在运行react项目时,由于不仔细出现了该问题。

TypeError: ctor is not a function

lazyInitializer

E:/React/react-17/node_modules/react/cjs/react.development.js:1275

  1272 | function lazyInitializer(payload) {
  1273 |   if (payload._status === Uninitialized) {
  1274 |     var ctor = payload._result;
> 1275 |     var thenable = ctor(); // Transition to the next state.
  1276 | 
  1277 |     var pending = payload;
  1278 |     pending._status = Pending;

View compiled

mountLazyComponent

E:/React/react-17/node_modules/react-dom/cjs/react-dom.development.js:17662

  17659 | var lazyComponent = elementType;
  17660 | var payload = lazyComponent._payload;
  17661 | var init = lazyComponent._init;
> 17662 | var Component = init(payload); // Store the unwrapped component in the type.
        | ^  17663 | 
  17664 | workInProgress.type = Component;
  17665 | var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);

View compiled

beginWork

E:/React/react-17/node_modules/react-dom/cjs/react-dom.development.js:19055

  19052 | case LazyComponent:
  19053 |   {
  19054 |     var elementType = workInProgress.elementType;
> 19055 |     return mountLazyComponent(current, workInProgress, elementType, updateLanes, renderLanes);
        | ^  19056 |   }
  19057 | 
  19058 | case FunctionComponent:

View compiled

HTMLUnknownElement.callCallback

E:/React/react-17/node_modules/react-dom/cjs/react-dom.development.js:3945

  3942 | function callCallback() {
  3943 |   didCall = true;
  3944 |   restoreAfterDispatch();
> 3945 |   func.apply(context, funcArgs);
       | ^  3946 |   didError = false;
  3947 | } // Create a global error event handler. We use this to capture the value
  3948 | // that was thrown. It's possible that this error handler will fire more

View compiled

invokeGuardedCallbackDev

E:/React/react-17/node_modules/react-dom/cjs/react-dom.development.js:3994

  3991 | // errors, it will trigger our global error handler.
  3992 | 
  3993 | evt.initEvent(evtType, false, false);
> 3994 | fakeNode.dispatchEvent(evt);
       | ^  3995 | 
  3996 | if (windowEventDescriptor) {
  3997 |   Object.defineProperty(window, 'event', windowEventDescriptor);

提示告诉我,ctor不是一个函数。这是因为 我在懒加载的时候写错了,如果引入的仅仅是组件名可以这样写,但是我写的是路径,所以这里犯了错误。正确的写法是

import { lazy } from "react";
// eslint-disable-next-line import/no-anonymous-default-export
export default {
    path:'/login',
    name:'login',
    component:lazy(()=>import('@/views/Login/index'))
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Zwq8023520

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

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

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

打赏作者

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

抵扣说明:

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

余额充值