如何将JSLint用于依赖于JQuery的代码段? [英] How can I use JSLint for a segment of code which depends on JQuery?

查看:63
本文介绍了如何将JSLint用于依赖于JQuery的代码段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Javascript比较陌生,我想运行我周末用JSLint玩的代码片段,以便它可以指出我是一个完全白痴的地方:)

I'm relatively new to Javascript, and I'd like to run the piece of code I spent the weekend playing with through JSLint so that it can point out where I was being a total idiot :)

不幸的是,我收到大量关于缺少函数声明的错误,这些声明是JQuery javascript库的一部分,也是它的各种插件。

Unfortunately, I get tons of errors about missing function declarations, which are part of the JQuery javascript library and various plugins for it.

有什么办法可以通过JSLint运行这样的代码吗?

Is there any way I can run such code through JSLint?

推荐答案

如果您使用的是 jslint ,您只需在预定义选项中添加 $ 对象:

If you're using the web version of jslint, you can simply add the $ object in the predefined option:

如果您使用的是jslint的本地副本,则需要将 predef 选项设置为 $ 选项对象中。

If you're using a local copy of jslint, you'd want to set the predef option to $ in the options object.

这篇关于如何将JSLint用于依赖于JQuery的代码段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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