javascript - 本地文件夹中的 console.log 问题

标签 javascript google-chrome console.log

我只是想知道我对 console.log 所做的事情是否错误。

我有两个简单的文件,如下所示: 索引.html 索引.js

当在chrome(c:\temp\index.html)中打开index.html时,它不会在控制台选项卡中输出console.log消息,如下所示。 enter image description here 那么我错过了什么吗?

如您所见,如果您在下面的代码中运行它,它将正确显示 console.log。

function doSomething() {
    console.log("Work!");
}

doSomething();
<!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>
    <div>Hi</div>
    <script scr='index.js'> </script>
</body>
</html>

最佳答案

您似乎有一个拼写错误:

<script scr='index.js'>

应该是

<script src='index.js'>

关于javascript - 本地文件夹中的 console.log 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51823533/

相关文章:

javascript - 当用户提交 PHP 表单时,如何将文本文件发送到网站上所有打开的浏览器

javascript - 我如何使用我无法控制 HTML 的表单上的按钮图像?

javascript - 使用javascript用图片而不是数字掷骰子的程序

javascript - 如何在 JavaScript 字符串中使用\n

javascript - .js 范围程序抛出错误

javascript - Autosuggest renderInputComponent - inputProps 类型的属性 'onChange' 不兼容

javascript - 无法捕获通过 Jquery Ajax 发送的 $_POST/$_GET

javascript - Chrome 扩展消息作为对象传递

html - 自动保存对 Chrome 开发工具中现有样式所做的 CSS 更改?

css - 在 Chrome 中停止水平滚动的指南