Javascript 无法加载资源 404 (Not Found) - 文件位置错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38081150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to load resource 404 (Not Found) - file location error?
提问by Roka545
I'm building an Angular 2 app which I just upgraded to Net Core RC2. Prior to the upgrade, my webpage would display just fine, but now I am getting errors in my Chrome Dev Tools console:
我正在构建一个刚刚升级到 Net Core RC2 的 Angular 2 应用程序。在升级之前,我的网页可以正常显示,但现在我的 Chrome Dev Tools 控制台出现错误:
Failed to load resource: the server responded with a status of 404 (Not Found):
http://localhost:5000/lib/bootstrap/dist/js/bootstrap.min.js
Failed to load resource: the server responded with a status of 404 (Not Found):
http://localhost:5000/lib/bootstrap/dist/css/bootstrap/bootstrap.min.css
I have bootstrap in my package.json file with version 3.3.6. I installed it with an npm installcommand. It installed properly in my Visual Studio project. The files are located at:
我的 package.json 文件中有 3.3.6 版的引导程序。我用npm install命令安装了它。它正确安装在我的 Visual Studio 项目中。这些文件位于:
project -> node_modules -> bootstrap -> dist -> js -> boostrap.min.js
项目 -> node_modules -> bootstrap -> dist -> js -> boostrap.min.js
and
和
project -> node_modules -> bootstrap -> dist -> css -> boostrap.min.css
项目 -> node_modules -> bootstrap -> dist -> css -> boostrap.min.css
My gulpfile has this section:
我的 gulpfile 有这个部分:
var config = {
libBase: 'node_modules',
lib: [
require.resolve('bootstrap/dist/css/bootstrap.min.css'),
require.resolve('bootstrap/dist/js/bootstrap.min.js'),
path.dirname(require.resolve('bootstrap/dist/fonts/glyphicons-halflings-regular.woff')) + '/**',
require.resolve('jquery/dist/jquery.min.js'),
require.resolve('chart.js/dist/Chart.bundle.min.js')
]
};
};
I'm also seeing a reference to bootstrap.min.js in a _Layout.cshtml file:
我还在 _Layout.cshtml 文件中看到了对 bootstrap.min.js 的引用:
<!doctype html>
<html lang="">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Homepage WebDev</title>
<base href="/" />
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
</head>
<body>
@RenderBody()
@RenderSection("scripts", required: false)
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="~/lib/chart.js/dist/Chart.bundle.min.js"></script>
</body>
</html>
I'm new to web development so I'm not completely sure what's happening. Could someone point me in the right direction?
我是网络开发的新手,所以我不完全确定发生了什么。有人能指出我正确的方向吗?
回答by Abhishek
Looks like the path you gave doesn't have any bootstrap files in them.
看起来您提供的路径中没有任何引导程序文件。
href="~/lib/bootstrap/dist/css/bootstrap.min.css"
Make sure the files exist over there , else point the files to the correct path, which should be in your case
确保文件存在于那里,否则将文件指向正确的路径,这应该是您的情况
href="~/node_modules/bootstrap/dist/css/bootstrap.min.css"