gpt4 book ai didi

javascript - Angular.js 加载脚本

转载 作者:行者123 更新时间:2023-12-02 17:15:37 24 4
gpt4 key购买 nike

我有一个使用 MEAN 堆栈的应用程序。当用户访问 URL 时:

http://localhost:3000/edit/0

其中 0 是记录 ID。这似乎可以正常工作,但我的脚本未加载到我的 edit.js 文件中:

<!doctype html>
<html>
<head>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css"></script>
<link rel="stylesheet" type="text/css" href="/css/style.css">

<script src="bower_components/jquery/jquery.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/ng-file-upload/angular-file-upload-shim.min.js"></script>

每个脚本和 css 文件的错误如下所示:

GET http://localhost:5000/edit/bower_components/jquery/jquery.min.js 404 (Not Found) 

所以很明显他们正在编辑目录而不是我的根目录中寻找脚本。我该如何解决这个问题?我需要在参数中传递 id,因为它是 GET。

最佳答案

除非您在 HTML HEAD 部分中指定“基本”标记或添加“/”来告诉浏览器使用您的域 + 绝对路径,否则浏览器会将相对路径添加到您的 URL 中以加载文件。因此,要么在路径之前添加“/”,要么添加“../”,或者添加基本标记。祝你好运

关于javascript - Angular.js 加载脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24473064/

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