在 Angular6 中使用 Bootstrap 的本地副本时出现错误

玛努查达

在我的项目中,我下载和 的本地副本但是当我将它们包含在项目中时出现错误BootstrapJqueryPopperAngular6

文件在位置 angular-test\src\assets\common

我已将他们的路径包含Angular.jsonprojects属性

 "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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章