TypeError: ‘undefined’ Is Not a Function

当调用未定义的函数时,Chrome 中就会发生这样的错误。
在这里插入图片描述
随着 JavaScript 编码技术和设计模式在过去几年中变得越来越复杂,回调和闭包中的自引用范围也相应增加,这是造成这种混乱现象的主要来源。

正如下面的示例代码片段:
在这里插入图片描述
执行上面的代码会导致以下错误:“Uncaught TypeError: undefined is not a function。” 发生以上错误的原因是,当你调用 setTimeout( ) 时,实际上是在调用 window.setTimeout( ),传递给 setTimeout( ) 的匿名函数是在窗口对象的上下文中定义的,而该窗口对象没有 clearBoard( ) 方法。

符合旧版浏览器的解决方案是以变量的方式简单地将引用保存在 this 中,然后通过闭包继承。例如:
在这里插入图片描述
或者,在较新的浏览器中,使用 bind( ) 方法传递引用:
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误通常发生在尝试迭代一个未定义的值时。"Uncaught (in promise) TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))"这个错误给出了一些线索。这意味着你在尝试对一个未定义的值进行迭代操作,而无法使用Symbol(Symbol.iterator)属性。根据提供的信息,可能是在进行懒加载配置时,有一些代码尝试对一个未定义的值进行迭代操作,导致报错。 要解决这个问题,你可以检查你的懒加载配置命令和相应的模块代码。确保你正确地导入和定义了需要迭代的值,并且该值不是未定义的。另外,你也可以检查代码中是否有其他地方尝试对未定义的值进行迭代操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#Object‘的...](https://download.csdn.net/download/weixin_38640984/13612199)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [ERROR Error: Uncaught (in promise): TypeError: undefined is not a function](https://blog.csdn.net/zhangbest2009/article/details/116134216)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [angular配置懒加载core.js:14597 ERROR Error: Uncaught (in promise): TypeError: undefined is not a ...](https://blog.csdn.net/zhangbest2009/article/details/102673598)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值