为什么console.log在javascript文件的Atom中不起作用?

问题描述 投票:0回答:1

Html file code I just tried the simple Hello World in javascript file

这是我无意使用console.log在控制台中显示消息。我使用了Atom,并在Chrome中打开了它,按inspect,进入控制台,但没有消息。

javascript atom-editor
1个回答
0
投票

[如果我们分别创建htmljavascript文件,则必须在javascript中将html文件指定为外部javascript文件。因此,在以上示例中,必须将<script src="index.js"></script>添加到html

下面提供完整的代码示例。

[C0的内容:

index.html

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Hello World with JS</title> </head> <body> <p>See the browser console for the console output.</p> <script src="index.js"></script> </body> </html>

index.js

关于console.log("Hello World!") javascript一起使用html的更多详细信息。

© www.soinside.com 2019 - 2024. All rights reserved.