繁体   English   中英

错误:Angular2 Plnkr中的(SystemJS)XHR错误(404)

[英]Error: (SystemJS) XHR error (404) in Angular2 Plnkr

错误:

在此处输入图片说明

https://plnkr.co/edit/910M73kwYKc8xPlSIU57?p=preview

指数

<!DOCTYPE html>
<html>

<head>
  <base href="/">
  <title>Angular 2.1.2 + TypeScript Starter Kit</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <script src="https://unpkg.com/zone.js@0.6.21/dist/zone.js"></script>
  <script src="https://unpkg.com/reflect-metadata@0.1.9/Reflect.js"></script>
  <script src="https://unpkg.com/systemjs@0.19.41/dist/system.js"></script>
  <script src="https://unpkg.com/typescript@2.1.4/lib/typescript.js"></script>
  <script src="config.js"></script>
  <script>
    System.import('app')
      .catch(console.error.bind(console));
  </script>
</head>

<body>
  <my-app>
    loading...
  </my-app>
</body>

</html>

目录

在此处输入图片说明

应用程序(app.module)

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';

import { routes } from './app.routing';

import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';
// import { AuthService } from './shared/services/auth.service';


@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    RouterModule.forRoot(routes)
  ],
  declarations: [
    AppComponent,
    LoginComponent
  ],
  providers: [
    // AuthService,
  ],
  bootstrap: [ AppComponent ]
})
export class AppModule {}

将我的config重命名为src/config但错误仍然存​​在。

用替换/ . 在您的<base href="/"> index.html文件中

<!DOCTYPE html>
<html>

<head>
  <base href=".">
  <title>Angular 2.1.2 + TypeScript Starter Kit</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <script src="https://unpkg.com/zone.js@0.6.21/dist/zone.js"></script>
  <script src="https://unpkg.com/reflect-metadata@0.1.9/Reflect.js"></script>
  <script src="https://unpkg.com/systemjs@0.19.41/dist/system.js"></script>
  <script src="https://unpkg.com/typescript@2.1.4/lib/typescript.js"></script>
  <script src="config.js"></script>
  <script>
    System.import('app')
      .catch(console.error.bind(console));
  </script>
</head>

<body>
  <my-app>
    loading...
  </my-app>
</body>

</html>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM