У меня есть приложение, поданное на localhost:4200
с ng serve
.
Когда я нажимаю localhost:4200/home
, все работает нормально.
Когда я нажимаю localhost:4200/vehicle/idKind/id
, Chrome пытается загрузить localhost:4200/vehicle/idKind/runtime.js
, чтоприводит к ошибке 404.
После проверки index.html
, сгенерированной угловым cli, я заметил, что теги сценария генерируются перед тегом html:
<script src="runtime.js" type="module"></script><script src="polyfills.js" type="module"></script><script src="styles.js" type="module"></script><script src="scripts.js" defer></script><script src="vendor.js" type="module"></script><script src="main.js" type="module"></script><script src="runtime.js" type="module"></script><script src="polyfills.js" type="module"></script><script src="styles.js" type="module"></script><script src="scripts.js" defer></script><script src="vendor.js" type="module"></script><script src="main.js" type="module"></script>
<!doctype html>
<html lang="fr">
<head>
<base href="/">
<!-- some scripts, stylesheets and fonts -->
<title>My app</title>
</head>
<app-root></app-root>
</html>
Когда я помещаю их вручную после <head>
(и <base href="/" />
) Chrome пытается загрузить localhost:4200/runtime.js
, что я и хочу.
My src/index.html
:
<!doctype html>
<html lang="fr">
<head>
<base href="/">
<!-- some scripts, stylesheets and fonts -->
<title>My app</title>
</head>
<app-root></app-root>
</html>
Почему теги сценариев генерируются до HTML?