【发布时间】:2017-03-26 15:56:16
【问题描述】:
我正在做一个简单的 Angular 2 教程,但在尝试运行我的应用程序时我只是得到“加载”。 这是我的 index.html 文件
<html>
<head>
<title>Angular CV </title>
<base href="/">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<!-- 1. Load libraries -->
<!-- Polyfill for older browsers -->
<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/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<!-- 3. Display the application -->
<body>
<my-app>Still Loading...</my-app>
</body>
</html>
app.component.ts
从'@angular/core'导入{组件}; @零件({ 选择器:'我的应用', 模板: '' }) 导出类 AppComponent { }【问题讨论】:
-
控制台有错误吗?
-
你应该执行 npm install reflect-metadata 和 npm install reflect-portfinder。
-
在 chrome 开发者工具中我得到以下错误 shim.min.js:2 Uncaught SyntaxError: Unexpected token ) and for index.html localhost/:18 Uncaught ReferenceError: System is not defined(…) System.import('app').catch(function(err){ console.error(err); });和directive_normalizer.js:92未捕获错误:模板解析错误:(...)-但我不确定它指的是代码的哪一部分...
-
从您的 github 存储库中,我认为您缺少
systemjs.config.js -
好的,我刚刚将 systemjs.config.js 添加到项目中,但应用程序仍然无法正常加载。它只是从我的 index.html 文件中读取加载...
标签: javascript angular