Angular2快速入门 - '无法获取'消息 [英] Angular2 Quick Start - 'Cannot Get' Message
本文介绍了Angular2快速入门 - '无法获取'消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试为Angular2做快速入门指南。我按照快速指南中的说明做了例子。但是,当我运行它时,它显示以下消息'无法获取'。有谁知道为什么会这样?
I've been trying to do the quick start guide for Angular2. I did the example as instructed in the quick guide. However, when I ran it, it displayed the following message 'Cannot Get'. Does anyone know why this is happening?
boot.js文件
// JavaScript source code
(function (app) {
document.addEventListener('DOMContentLoaded', function () {
ng.platform.browser.bootstrap(app.AppComponent);
});
})(window.app || (window.app = {}));
app.component.js文件
(function (app) {
app.AppComponent = ng.core.Component({
Selector: 'my-app',
template: '<h1>My First Angular 2 App </h1>'
})
.class({
constructor: function () { }
});
})(window.app || window.app == {});
索引文件
<html>
<head>
<title>Angular 2 QuickStart</title>
<!-- 1. Load libraries -->
<script src="https://code.angularjs.org/2.0.0-beta.0/angular2-polyfills.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/Rx.umd.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/angular2-all.umd.dev.js"></script>
<!-- 2. Load our 'modules' -->
<script src='app/app.component.js'></script>
<script src='app/boot.js'></script>
</head>
<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>
</html>
最后,package.json文件
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "npm run lite",
"lite": "lite-server"
},
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-beta.0",
"systemjs": "0.19.6",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.10"
},
"devDependencies": {
"lite-server": "^1.3.1"
}
}
我跑了'npm'开始'打开浏览器并显示'无法获取'
I ran the line 'npm start' which opened the browser and displayed 'Cannot Get'
推荐答案
我弄清楚问题是什么。我的html文件中有一个额外的空间导致错误。我删除了额外的空间,它按预期工作。
I figured out what the issue was. I had an extra space in my html file which was causing the error. I removed the extra space, and it worked as expected.
这篇关于Angular2快速入门 - '无法获取'消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文