我是JavaScript新手。我试图吐出一些东西到Chrome控制台,但我得到这些错误在JSLint的括号:Javascript:正在使用'严格'错误
'$' was used before it was defined. $(document).on("ready", function() {
3 Expected exactly one space between 'function' and '('. $(document).on("ready", function() {
4 Missing 'use strict' statement. console.log("Address Explorer JS up and running.");
4 Expected 'console' at column 5, not column 3. console.log("Address Explorer JS up and running.");
4 'console' was used before it was defined. console.log("Address Explorer JS up and running.");
这里是JS代码:
"use strict";
/* address-explorer.js */
$(document).on("ready", function() {
console.log("Address Explorer JS up and running.");
});
我尝试添加了“使用严格的”;声明在文件的顶部,但这些错误不会消失,也不会向控制台吐出。这里是HTML:
<!DOCTYPE html>
<html>
<head>
<title>My Address Explorer</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css" rel="stylesheet">
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="./address-explorer.js"></script>
</head>
<body>
<div class="container">
<h1 class="twelve coloumns">
Your Account
</h1>
<div class="five coloumns">
<span id="displayed_balance" class="value"> </span>
<br><span class="label"> Total Balance</span>
</div>
<div class="four coloumns">
<span id="transaction_count" class="value"> </span>
<br><span class="label"> Transactions</span>
</div>
<div class="two coloumns">
<span id="blocks_mined_count" class="value"> </span>
<br><span class="label">Blocks Mined</span>
</div>
<h4 class="twelve columns">Activity</h4>
</div>
</body>
</html>
帮助将不胜感激。
您使用的是JSLinter吗?这些看起来像lint错误 - 如果是这样,你需要指定开发模式。一些像控制台或窗口这样的常量全局变量会抛出这个错误。忽略它。 –
这听起来像你还没有加载jQuery ... – rnevius
@Meeseeks我已经添加了jQuery脚本,并且html和js都在同一个文件中。 – Shashank