登录MIME类型('text / html')不是受支持的样式表MIME类型

时间:2018-07-25 19:45:31

标签: html css angular

这是我用于index.html的代码段

enter image description here

但是,每当我运行此应用程序时,我都会遇到错误

enter image description here

请帮助

这是我的.angular-cli.json文件。此代码段可能包含一些代码。我试图弄清楚,但没有。 \有人可以帮忙-

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "retro-build-con"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "src/tsconfig.spec.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "e2e/tsconfig.e2e.json",
      "exclude": "**/node_modules/**"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

1 个答案:

答案 0 :(得分:1)

您正在尝试加载的CSS文件似乎已重定向到HTML页面(可能是由于路由)。

您需要像这样修改assets块:

  "assets": [
    "assets",
    "favicon.ico",
    "css"
  ],

这样,CSS目录将正确地提供其静态内容

或者,您可以将CSS目录移入资产目录,并将路径更改为:

href="assets/css/bootstrap.min.css"

完成更改后,请确保再次停止调用ng serve以重新启动开发服务器