在已经设置route的情况下,以table为例,可以如下设置,范围为对应的模版;

App.TableView = Em.View.extend({
});
App.TableIndexView = Em.View.extend({
});

也可以通过如下新建,其获得的this为所在模版的this;

{{#view InnerView}}......{{/view}}

InnerView = Ember.View.extend({});

简单设置:

  • 设置整体的标签:
    • tagName
  • 设置class:
    • classNames:[](适合固定值);
    • classNameBinds[](这个要通过其他属性设置或方法返回,适合变值),同样使用在template设置classname的方法,如 ['isEnabled:enabled:disabled']
  • 设置其他attr属性

设置event方法:设置的方法配置在view内所有的element上;

使用模版:模版当中的书写格式与html模版相同;

   template: Ember.Handlebars.compile(""),

使用didInsertElement:在render和dom加载完之后执行,此外还有其他在不同时机执行的方法

  以tables和table为例在不同url跳转时候的执行:

  •  x/x  ->  x/tables: 同时执行tablesIndexView和tablesView;
  •  x/tables -> x/tables/id1: 只执行 tableview;
  •  x/tables/id1 -> x/tables/id2 : 都不执行;
  •  x/tables/id1  ->  x/tables: 只执行tablesIndexView;

在x/tables/id1 -> x/tables/id2 之间跳转的时候,可以在controller中定义一个方法

相关文章:

  • 2022-12-23
  • 2021-07-19
  • 2021-04-12
  • 2022-12-23
  • 2021-09-14
  • 2022-03-05
  • 2021-08-05
猜你喜欢
  • 2021-12-06
  • 2021-09-21
  • 2021-10-24
  • 2021-10-24
  • 2021-08-19
  • 2021-08-08
  • 2021-12-03
相关资源
相似解决方案