问题描述
我通过 bash 创建了一个新的 Foundation 5 项目,使用 foundation new my-project
.当我在 Chrome 中打开 index.html 文件时,控制台中会显示 Uncaught TypeError: a.indexOf is not a function
错误,该错误源自 jquery.min.js:4
.
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
.
我按照基础站点上的步骤创建了项目,但我似乎无法摆脱这个错误.Foundation 和 jQuery 看起来像是在 index.html 文件中包含并正确链接,链接的 app.js 文件包含 $(document).foundation();
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?
推荐答案
这个错误可能是由 jQuery 事件别名引起的,比如 .load()
, .unload()
或 .error()
从 jQuery 1.8 开始,所有这些都弃用.在您的代码中查找这些别名并将它们替换为 .on()
方法代替.例如,替换以下已弃用的摘录:
This error might be caused by the jQuery event-aliases like .load()
, .unload()
or .error()
that all are deprecated since jQuery 1.8. Lookup for these aliases in your code and replace them with the .on()
method instead. For example, replace the following deprecated excerpt:
$(window).load(function(){...});
具有以下内容:
$(window).on('load', function(){ ...});
这篇关于“未捕获的类型错误:a.indexOf 不是函数";打开新的基础项目时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!