简体   繁体   中英

Error: (SystemJS) XHR error (404) in Angular2 Plnkr

The error:

在此处输入图片说明

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

index

<!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>

Directory

在此处输入图片说明

app (the 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 {}

Renamed my config to src/config but error remains.

Replace / with . in your <base href="/"> index.html file

<!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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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