简体   繁体   English

Javascript图块未加载

[英]Javascript tile doesn't load

The javascript file(sript1) doesn't load when i open the test page and they are in the same folder.(I am using sublime text). 当我打开测试页时,javascript文件(sript1)无法加载,它们位于同一文件夹中。(我使用的是崇高的文字)。

The test page 测试页

<!DOCTYPE html>
<html>
<head>
    <title></title>

</head>
<body>
    <h1>Test</h1>
    <script src="script1.js"></script>

</body>
</html>

The script1.js page script1.js页面

var database = [
{
    username:"boss",
    password:"super"
}
];

var newFeed = [
{
    username="Bob",
    timeline="whatsssupp"
},
{
    username="Sally",
    timeline="cooooool"

}
];

var userNamePrompt= prompt("What is your username");
var passwordPropmt=prompt("Whats your password");

Most likely your JS file is loaded (and running), but it contains errors so it doesn't show the prompts as you expected it to. 极有可能您的JS文件已加载(并正在运行),但其中包含错误,因此不会按预期显示提示。 You are using = instead of : when assigning a value to an object (newFeed). 将值分配给对象(newFeed)时,将使用=而不是:

Test whether fixing your code works for you, like so: 测试修复代码是否适合您,如下所示:

var database = [
    {
        username: "boss",
        password: "super"
    }
];

var newFeed = [
    {
        username:"Bob",
        timeline:"whatsssupp"
    },
    {
        username:"Sally",
        timeline:"cooooool"

    }
];

var userNamePrompt = prompt("What is your username");
var passwordPropmt = prompt("Whats your password");

In the case that it didn't fix your issue, then it could be one of the following: 如果它不能解决您的问题,则可能是以下之一:

  • permission issue; 权限问题; ensure that you have the right permissions 确保您拥有正确的权限
  • the file path or name is incorrect; 文件路径或名称不正确; always double check your paths and names; 始终仔细检查您的路径和名称;
  • other reasons we can not see from here 我们从这里看不到的其他原因

Whatever the reason might be, most browsers nowadays have something called 'Developer Tools' which can be opened using the F12 hotkey. 不管是什么原因,当今大多数浏览器都具有一个称为“开发人员工具”的东西,可以使用F12热键打开它。 Then you will be able to see in the console if JavaScript code goes wrong: 然后您将能够在控制台中查看JavaScript代码是否出错:

Firefox : https://developer.mozilla.org/en-US/docs/Tools Firefoxhttps//developer.mozilla.org/en-US/docs/Tools

Chrome : https://developers.google.com/web/tools/chrome-devtools/ Chrome浏览器https : //developers.google.com/web/tools/chrome-devtools/

IE : https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/hh968260(v=vs.85) IEhttps//docs.microsoft.com/zh-CN/previous-versions/windows/desktop/legacy/hh968260(v = vs.85)

EDGE : https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide 边缘https : //docs.microsoft.com/zh-cn/microsoft-edge/devtools-guide

THAT error will tell you exactly what is going wrong with your setup. 该错误将告诉您确切的设置问题。 Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM