【发布时间】:2018-12-31 11:43:19
【问题描述】:
我正在尝试在 chrome 中控制台登录。只是基本的东西。这是我的 html 文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>hello</h1>
<button onClick="clickme()">click</button>
<script type="text/javascript" src="index.js"></script>
</body>
</html>
现在我的 js 文件包含
var name="abc";
console.log("hello " + name);
clickme=()=>{
document.body.style.backgroundColor="red";
alert(name);
console.log("hello " + name);
}
警报有效。背景图像在按钮单击时发生变化,但 console.log 不起作用。它使用节点 js 和在边缘浏览器中使用时工作。
是不是少了点什么。
【问题讨论】:
-
关闭警告框后是否打印?警报将停止执行。
-
console.log都不起作用? -
不,它没有。即使我的整个 js 文件中只有 console.log("hello") ,它也不起作用。如果我输入console.log(“whatever”)它说未定义,另一个有线的东西是在chrome控制台中。
-
从您上面发布的代码中,您的两个
console.log()语句都可以正常工作。你的问题在别处。请确保您已提供问题的minimal, complete, and verifiable example。 -
您是否在
filter字段中写了一些东西(可能是偶然的)?
标签: javascript