“Uncaught TypeError:a.indexOf不是函数”开设新基础项目时出错 [英] "Uncaught TypeError: a.indexOf is not a function" error when opening new foundation project

查看:165
本文介绍了“Uncaught TypeError:a.indexOf不是函数”开设新基础项目时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过bash创建了一个新的Foundation 5项目,其中 foundation new my-project 。当我在Chrome中打开index.html文件时,控制台中显示 Uncaught TypeError:a.indexOf不是函数错误显示在控制台中,源自 jquery .min.js:4



我按照基金会网站上的步骤创建了项目,但似乎无法摆脱的这个错误。 Foundation和jQuery看起来好像包含在index.html文件中并正确链接,并且链接的app.js文件包含 $(document).foundation();

有谁知道是什么原因导致了这个错误?以及可能的解决方案是什么?



解决方案

这个错误可能是由jquery事件别名引起的,例如 .load .unload .error 从jQuery 1.8开始弃用。在代码中查找这些别名,并用 .on()替换它们来注册监听器。示例:

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



成为:

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


I've created a new Foundation 5 project through bash, with foundation new my-project. When I open the index.html file in Chrome an Uncaught TypeError: a.indexOf is not a function error is shown in the console, originating in jquery.min.js:4.

I created the project following the steps on the foundation site, but I can't seem to get rid of this error. Foundation and jQuery look like they are included and linked up correctly in the index.html file, and the linked app.js file is including $(document).foundation();

Does anyone know what is causing this error? and what a solution might be?

解决方案

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. Example:

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

becomes:

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

这篇关于“Uncaught TypeError:a.indexOf不是函数”开设新基础项目时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆