在我的项目中,我下载了、和 的本地副本。但是当我将它们包含在项目中时出现错误。Bootstrap
Jquery
Popper
Angular6
文件在位置 angular-test\src\assets\common
我已将他们的路径包含Angular.json
在projects
属性下。
"projects": {
"angular-test":
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css",
"src/assets/common/css/vendor/bootstrap/bootstrap.css"
],
"scripts": [
"src/assets/common/javascripts/vendor/jquery/jquery-3.2.1.js",
"src/assets/common/javascripts/vendor/popper/umd/popper.js",
"src/assets/common/javascripts/vendor/bootstrap/bootstrap.js"
]
},
并在它们中使用index.html
如下:
<head>
...
<link rel="stylesheet" media="screen" href="bootstrap.css">
</head>
<body>
<app-root signup="success1"></app-root>
<script src="jquery-3.2.1.js" type="text/javascript"></script>
<script src="popper.js" type="text/javascript"></script>
<script src="bootstrap.js")" type="text/javascript"></script>
</body>
我得到的错误是
Refused to apply style from 'http://localhost:4200/bootstrap.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
jquery-3.2.1.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
localhost/:1 Refused to execute script from 'http://localhost:4200/jquery-3.2.1.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
popper.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
localhost/:1 Refused to execute script from 'http://localhost:4200/popper.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
bootstrap.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
localhost/:1 Refused to execute script from 'http://localhost:4200/bootstrap.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
问题是,因为我已经在scripts
属性中指定了 javascripts Angular.json
,所以我不需要在index.html
. 我评论了以下内容并且它起作用了
<!--script src="jquery-3.2.1.js" type="text/javascript"></script>
<script src="popper.js" type="text/javascript"></script>
<script src="bootstrap.js" type="text/javascript"></script-->
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句