gpt4 book ai didi

javascript - Angular4导入本地js文件提示404 not found

转载 作者:行者123 更新时间:2023-11-30 20:59:28 25 4
gpt4 key购买 nike

我使用“ng new xxx”建立了一个新项目, 只需在 index.html 中添加一行:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bbb</title>
<base href="/">

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">

</head>
<body>
<app-root></app-root>
<script type="text/javascript" src="./CitrixHTML5SDK.js"></script>
</body>
</html>

然后把js文件放在和index.html相同的目录下

the same dir

但是当我运行“ng server”时,浏览器总是显示:404

the js file not found

有人知道为什么吗?提前致谢。

最佳答案

我遇到了与 JSON 文件相同的问题,所以我所做的是将我的 JSON 文件保存到 assets 文件夹中。并通过我的代码访问它。

这里是Project file review你也可以验证它。

关于javascript - Angular4导入本地js文件提示404 not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47277615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com