javascript - 为什么我得到一个错误,即找不到 app.js 文件?
问题描述
在这里,这是我的文件夹结构:
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 文件不在脚本文件夹中。
<script src="---------> ../scripts/app.js <--------" type="text/javascript" ></script> // Here is the script tag
您可能应该使用此路径:
<script src="../app.js" type="text/javascript" ></script> // Here is the script tag
推荐阅读
- r - 返回 R 中前五列的函数
- sql-server - 如何检测它是 VB.NET 上的重复条目?
- php - 根据单选按钮显示/隐藏 WooCommerce 运费
- ios - HTML5 Video mp4 无法在某些 iPad 上播放
- python - 在 Python 正则表达式中处理“NoneType”
- asp.net-core - Asp.net core 3 Unicode slug url段作为控制器HttpGet操作方法中的参数没有收到任何url段值
- sql-server - 尝试对表中具有相同后缀的数据进行计数
- java - Jackson 2:无法将类型 id 'C' 解析为 `test.protocol.StatusEventObject 的子类型
- r - 在 R 中不使用 lme4 包估计混合级逻辑回归系数
- java - 访问 Firestore 时出现无效的集合引用错误