我无法在xammp上运行Angular应用程序

时间:2016-04-12 07:41:16

标签: angular

我刚开始学习Angular。我已经在Windows中的xammp服务器上设置了项目。这是我的项目结构:

C:\xampp\htdocs\loginAngular

loginAngular文件夹内有:

1)app
2)node_modules
3)typings
4)index.html

我的索引文件如下:

<html>
  <head>
    <base href="/">
    <!-- 1. Load libraries -->
    <!-- IE required polyfills, in this exact order -->
    <script src="node_modules/es6-shim/es6-shim.min.js"></script>
    <script src="node_modules/systemjs/dist/system-polyfills.js"></script>

    <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="node_modules/rxjs/bundles/Rx.js"></script>
    <script src="node_modules/angular2/bundles/angular2.dev.js"></script>
    <script src="node_modules/angular2/bundles/router.dev.js"></script>

    <script src="https://code.jquery.com/jquery-2.2.1.min.js" ></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"></script>

    <link rel="stylesheet" href="style.css"></link>

    <!-- 2. Configure SystemJS -->
    <script>
      System.config({
        packages: {        
          app: {
            format: 'register',
            defaultExtension: 'js'
          }
        }
      });
      System.import('app/main')
            .then(null, console.error.bind(console));
    </script>

  </head>

  <!-- 3. Display the application -->
  <body>
    <my-app>Loading...</my-app>
  </body>
</html>

我在控制台中收到此错误:

"NetworkError: 404 Not Found - http://localhost/app/main.js"

2 个答案:

答案 0 :(得分:0)

<base href="/">更改为<base href="./">,使您的路径相对于http://localhost/loginAngular而不是http://localhost

答案 1 :(得分:0)

<base href="/">更改为

<script>document.write('<base href="' + document.location + '" />');</script>