1. 问题

浏览器报错说 e.indexOf is not a function,我们发现这是jquery在调用 load 方法时报错
在这里插入图片描述

2. 原因

因为 load 方法已经在 jquery 1.8的版本中弃用了
在这里插入图片描述

This error might be caused by jquery event aliases like .load, .unload or .error deprecated since jQuery 1.8. Look for these aliases in your code and replace them with .on() to register listeners instead.

 $(window).load(function(){...});

3. 解决方案

通过 on 方法在选定的元素上绑定 load 监听事件.

$(window).on('load',function(){...})
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐