如何修复“foo未定义” JSlint报告的错误? [英] How to fix "foo is not defined" error reported by JSlint?

查看:128
本文介绍了如何修复“foo未定义” JSlint报告的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

JSLint:在定义之前使用过

我运行 JSlint 并看到类似的错误:

I run JSlint and saw errors like that:

'foo' is not defined.
var x = foo();

foo 是另一个定义的函数code> JavaScript 文件 foo.js 。据我所知, JavaScript 中没有import / require指令来引用另一个源文件中定义的 foo 函数。

foo is a function defined in another JavaScript file foo.js. As I understand there is no "import / require" directives in JavaScript to reference the foo function defined in another source file.

如何解决由 JSlint 重新设置的错误?

How can I fix this error repoted by JSlint?

推荐答案

使用global指令告诉JSLint关于 foo 的假设存在。

Use the global directive to tell JSLint about foo's assumed existence.

/*global foo */

http://www.jslint.com/help.html#global

这篇关于如何修复“foo未定义” JSlint报告的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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