angular2 univesral - 警告:您的应用程序需要很长时间才能呈现应用程序

时间:2016-08-26 11:38:41

标签: angular angular2-universal

我在开发模式下使用angular2 universal进行简单测试。

我在日志中收到此消息:

WARNING: your application is taking a long time to render the application

我同意...... jeesh需要几秒钟才能加载。我如何重新爱好?我在我的Mac上本地运行。

因此,从请求发出请求的时间大约是90秒。然后我的api服务器被点击,我看到2个请求。所以它不是api服务器,这是烧瓶fyi。如果我重新加载相同的请求然后快速。只有新的端点。

这是我的应用组件:

import { Component, OnInit } from '@angular/core';
import {RouterLink,Router,ActivatedRoute,ROUTER_DIRECTIVES} from '@angular/router';
import { TestService } from '../service/test.service';

@Component({
  moduleId: __filename,
  directives: [RouterLink,ROUTER_DIRECTIVES],
  providers: [ TestService],
  styles: [],
  template: `
      {{state}}
      <br>
      {{city}}
      <br>
      {{report_list | json}}
  `
})
export class TestComponent implements OnInit {

  isLoading=true;
  state:string;
  city:string;
  report_list: any[] = [];

  constructor(private route: ActivatedRoute,
              private _TestService:TestService
              ) { }

  ngOnInit() {

    this.route.params.map(params => params['state'])
            .subscribe(state => { this.state=state });
    this.route.params.map(params => params['city'])
            .subscribe(city => { this.city=city });

    this._TestService.getData(this.state,this.city)
                .subscribe(report_list => this.report_list = report_list,
                null,() => { this.isLoading = false; });
  }

}

0 个答案:

没有答案