刚刚看一下角度团队发布的最后一个角度版本。 Angular2已经出局,他们已经发布了新的网页http://angular.io。
在那里,他们有一个5分钟的快速入门项目,可以快速显示新语法以及您必须使用什么来执行新的角度应用程序。
我刚刚完成了所有步骤以使其正常工作,但加载时间为4.93秒。
我只是想知道,角度2那么慢吗?或者我可能会错过一些步骤。
这是我的代码
// app.es6
import {Component, Template, bootstrap} from 'angular2/angular2';
// Annotation section
@Component({
selector: 'my-app'
})
@Template({
inline: '<h1>Hello {{ name }}</h1>'
})
// Component controller
class MyAppComponent {
constructor() {
this.name = 'Alex!';
}
}
bootstrap(MyAppComponent);
和index.html
<!-- index.html -->
<html>
<head>
<title>Angular 2 Quickstart</title>
<script src="dist/es6-shim.js"></script>
</head>
<body>
<!-- The app component created in app.js -->
<my-app></my-app>
<script>
// Rewrite the paths to load the files
System.paths = {
'angular2/*':'angular2/*.js', // Angular
'rtts_assert/*': 'rtts_assert/*.js', //Runtime assertions
'app': 'app.js' // The my-app component
};
// Kick off the application
System.import('app');
</script>
</body>
</html>
答案 0 :(得分:30)
请参阅https://github.com/djsmith42/angular2_calendar了解如何让它快速运行。
答案 1 :(得分:4)
是的,使用angular2编写的页面很慢。
我不是说angular2代码很慢(我不敢),只是你可以使用angular写的最简单的页面将在5秒或更长时间内加载。有很多文件需要加载。 确实,你可以通过组合文件来加快速度,这样你就可以获得更少的http请求,并且小心不加载你不使用的东西,但它永远不会像简单的html + js页面一样快。
重要的是要记住,angular是专为单页应用而设计的。所有依赖项在一个索引文件中加载一次,从那时起,角度路由允许您导航到不同的页面&#34;,这实际上只是模板文件。
换句话说,一旦完成了重大的前期打击,它可以非常快,最重要的是,非常高效。
答案 2 :(得分:1)
如果对于最新版本的alpha27,你会逐行遵循QuickStart教程,因为System.js和angular2.min.js文件需要很长时间才能加载,所以它会变慢。更好的是,如果您可以使用我们自己的服务器来托管它们。而且,从您的代码中,您似乎正在使用pre-alpha20代码库。升级到alpha27,它的速度要快得多。