【问题标题】:Asp.net Core with Angular 2 main.js Path Error带有 Angular 2 main.js 路径错误的 Asp.net Core
【发布时间】:2017-12-24 11:40:45
【问题描述】:

我正在借助 Angular Quickstart 使用 Angular 2 构建 asp.net 核心应用程序。

由于 Asp.Net 核心应用程序允许 wwwroot 作为文件夹,我将所有依赖项移动到该文件夹​​,包括节点模块。

Layout.cshtml

    <script src="/node_modules/core-js/client/shim.min.js"></script>
    <script src="/node_modules/zone.js/dist/zone.js"></script>
    <script src="/node_modules/systemjs/dist/system.src.js"></script>

    <script src="~/src/systemjs.config.js"></script>
    <script>
        System.import('main.js').catch(function (err) { console.error(err); });
    </script>

ts.Config.json

{
  "compileOnSave": true,
  "compilerOptions": {
    "importHelpers": true,
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "removeComments": true,
    "outDir": "wwwroot/src"

  }
}

现在我面临以下错误:

http://localhost:18929/main.js 404(未找到)
(index):45 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:18929/main.js

【问题讨论】:

    标签: asp.net angular asp.net-core-1.1


    【解决方案1】:

    请尝试在 html 的标题中添加以下内容

    <base href="/" />
    

    【讨论】:

    猜你喜欢
    • 2018-06-02
    • 2017-12-09
    • 2018-10-22
    • 1970-01-01
    • 2017-08-31
    • 2017-12-03
    • 1970-01-01
    • 2018-02-17
    • 1970-01-01
    相关资源
    最近更新 更多