Jos*_*ice 30 javascript node.js angular
我一直在尝试为Angular2做快速入门指南.我按照快速指南中的说明做了例子.但是,当我运行它时,它显示以下消息'无法获取'.有谁知道为什么会这样?
boot.js文件
// JavaScript source code
(function (app) {
document.addEventListener('DOMContentLoaded', function () {
ng.platform.browser.bootstrap(app.AppComponent);
});
})(window.app || (window.app = {}));
Run Code Online (Sandbox Code Playgroud)
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 == {});
Run Code Online (Sandbox Code Playgroud)
索引文件
<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>
Run Code Online (Sandbox Code Playgroud)
最后是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"
}
}
Run Code Online (Sandbox Code Playgroud)
我跑了'npm start'这一行打开浏览器并显示'Can not Get'
Mel*_*laz 54
当index.html不在正确的文件夹中时,我收到此错误.
如果是这种情况,将它放在主角度项目的根文件夹中应该可以解决错误.
我遇到了同样的问题:Cannot GET / pagename
在每一页上.我搜索了互联网,但没有找到像这样的解决方案.
我的项目位于一个带有ASCII空格的文件夹中,因为存储库名称也包含空格.
项目所在的文件夹不应包含任何空格或ASCII字符"%20".
在此更改后,我的项目没有给出Cannot GET / pagename
错误.
归档时间: |
|
查看次数: |
20889 次 |
最近记录: |