我正在开发一个级联视图的主干应用程序。有一个根视图在其initialize
方法内部创建其子视图,并在其自己的内部调用子视图渲染render
。它可能如下所示:
initialize: function(options) {
console.log('body');
this.template = tpl({});
this.headerView = new HeaderView(options);
this.chartView = new ChartView(options);
this.footerView = new FooterView(options);
},
render: function() {
console.log("body");
this.$el.html(this.template);
this.headerView.setElement(this.$el.find('.header')).render();
this.chartView.setElement(this.$el.find('.chart')).render();
this.footerView.setElement(this.$el.find('.footer')).render();
return this;
}
所有子视图都以相同的方式进行——它们将自己呈现在自己的render
方法中并调用render
它们的子视图。
我的问题是:为什么在最后一个视图完成渲染后会显示整个页面?我的页面非常复杂,加载需要 4 秒,同时我有一个空白页面。我有很多控制台输出,我清楚地看到,其中一些视图已经呈现。
我不明白为什么没有即时显示如此大量的 HTML。我不希望它是那样的。