在使用编码在jslint和jshint中定义"$"之前,如何修复"$"? [英] How to fix '$' was used before it was defined in both jslint and jshint using coding?
本文介绍了在使用编码在jslint和jshint中定义"$"之前,如何修复"$"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 jQUery .在 jslint 中,我继续
I am using jQUery . And in jslint, I keep on
'$' was used before it was defined.
或
document was used before it was defined.
我知道我可以通过使用
/*jslint browser: true*/
/*global $, jQuery*/
但是我想尽可能地通过编码解决此问题.所以,我以前很喜欢.
But I wanted to actually fix this through coding if possible. So, I did like before.
var $, document;
$(document).ready(function () {
"use strict";
但是,现在显示
Two warnings
1 Redefinition of '$'.
1 Redefinition of 'document'.
在 jshint 中.是否可以使用 jshint和jslint 编码?
in jshint. Is there a coding that I can use to please both jshint and jslint?
推荐答案
请使用jslint注释.以下建议使用一些技巧.在代码中使用技巧将不利于可维护性.这是代码:
Please use jslint comments. The following suggestion uses a few tricks. Having tricks in your code won't help for maintainability. Here is the code:
var myApplication = function () {
"use strict";
var $ = this.$, document = this.document, console = this.console;
$(document).ready(function () {
//...
console.log("test");
});
};
myApplication.call(this);
这篇关于在使用编码在jslint和jshint中定义"$"之前,如何修复"$"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文