最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Failed to load resource: net::ERR_FILE_NOT_FOUND in angular - Stack Overflow

programmeradmin1浏览0评论

I build my app using electron and these errors occurred in chrome console. Otherwise my app is working fine if I run it through ng serve. Errors are as follows:

Failed to load resource: net::ERR_FILE_NOT_FOUND
polyfills.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
styles.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
vendor.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
main.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
/C:/favicon.ico:1 Failed to load resource: net::ERR_FILE_NOT_FOUND

My index.html file in dist folder is:

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

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="styles.50e334ed602d9817f7d7.bundle.css" rel="stylesheet"/></head>
<body>

 <app-root>Loading...</app-root>

<script type="text/javascript" src="inline.9c6676de3e2948b5be6b.bundle.js"></script><script type="text/javascript" src="polyfills.e19c18e1070c8c3aa743.bundle.js"></script><script type="text/javascript" src="vendor.e2a9b8f51e6c245f32be.bundle.js"></script><script type="text/javascript" src="main.eb7ca8d005a358b399e4.bundle.js"></script></body>
</html>

and code of my index.html file in src folder is:

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>IMS</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>Loading...</app-root>

</body>
</html>

I build my app using electron and these errors occurred in chrome console. Otherwise my app is working fine if I run it through ng serve. Errors are as follows:

Failed to load resource: net::ERR_FILE_NOT_FOUND
polyfills.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
styles.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
vendor.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
main.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
/C:/favicon.ico:1 Failed to load resource: net::ERR_FILE_NOT_FOUND

My index.html file in dist folder is:

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

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="styles.50e334ed602d9817f7d7.bundle.css" rel="stylesheet"/></head>
<body>

 <app-root>Loading...</app-root>

<script type="text/javascript" src="inline.9c6676de3e2948b5be6b.bundle.js"></script><script type="text/javascript" src="polyfills.e19c18e1070c8c3aa743.bundle.js"></script><script type="text/javascript" src="vendor.e2a9b8f51e6c245f32be.bundle.js"></script><script type="text/javascript" src="main.eb7ca8d005a358b399e4.bundle.js"></script></body>
</html>

and code of my index.html file in src folder is:

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>IMS</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>Loading...</app-root>

</body>
</html>
Share Improve this question edited May 29, 2018 at 8:19 Ilona 3573 silver badges10 bronze badges asked May 29, 2018 at 4:43 junaidjunaid 931 gold badge1 silver badge8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

https://angular.io/docs/ts/latest/guide/router.html

Add the base element just after the <head> tag. If the app folder is the application root, as it is for our application, set the href value exactly as shown here.

The <base href="/"> tells the Angular router what is the static part of the URL. The router then only modifies the remaining part of the URL. Set your Base href to '/' in your src/index.html

<base href="/"> 

You can learn more about base href here

For me this worked fine both for ng serve and ng build:

<base href="">
发布评论

评论列表(0)

  1. 暂无评论