Javascript 为什么出现错误,即找不到app.js文件?

Javascript 为什么出现错误,即找不到app.js文件?,javascript,html,Javascript,Html,这里是我的文件夹结构: ReactCourse // It is the root directory public // public is the subfolder in ReactCourse index.html // It is the html file where I linked the js file into html page app.js // It is the app.js file 以下是i

这里是我的文件夹结构:

 ReactCourse      // It is the root directory
    public        // public is the subfolder in ReactCourse
      index.html  // It is the html file where I linked the js file into html page
    app.js        // It is the app.js file 
以下是index.html文件:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>React App</title>
</head>
<body class="root">
    <h1>I am header</h1>
    <script src="../app.js" type="text/javascript" ></script> // Here is the script tag
</body>
</html>
 

反应应用程序
我是头球手
//这是脚本标签
//但不幸的是,我得到了一个错误,即在控制台上找不到文件


//当我将app.js文件放入公用文件夹时,效果很好

根据您的文件结构,您的app.js文件不在脚本文件夹中

//这是脚本标签

您可能应该使用以下路径:


//这是脚本标记

您的脚本标记在路径中有目录名
/scripts/
,但没有这样的目录。
@Hemant-您之前到底尝试了什么?你所描述的你曾经工作和没有工作是没有意义的。