第一次使用 angular2 ,按照以下说明5 分钟快速入门指南 https://angular.io/docs/ts/latest/quickstart.html#对于角度 2。
一切正常,意味着运行时没有错误npm start
npm 启动镜像 https://i.stack.imgur.com/c8Pq7.png
但当我打开时
本地主机:3000
it show 加载中...不期望的文本。根据这个示例,index.html 的内容应该反映这一点。
在控制台中有错误:
异常:类型错误:无法将属性“endSourceSpan”设置为 null
main.ts
import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
bootstrap(AppComponent);
应用程序组件.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: 'My first Angular 2 App</h1>'
})
export class AppComponent {}
索引.html
<html>
<head>
<title>Angular 2 QuickStart</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/es6-shim/es6-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>Loading...</my-app>
</body>
</html>
请帮我看看出了什么问题。
我认为你的主要组件的模板有问题。例如,未正确关闭的 HTML 元素:
template : '<div</div>'
请参阅此问题了解更多详细信息:
- https://github.com/angular/angular/issues/7849 https://github.com/angular/angular/issues/7849
Edit
问题是你的h1
不正确(没有开始元素):
@Component({
selector: 'my-app',
template: '<h1>My first Angular 2 App</h1>' // <------
})
export class AppComponent {}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)