博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ember.js:使用笔记5 使用view
阅读量:4662 次
发布时间:2019-06-09

本文共 862 字,大约阅读时间需要 2 分钟。

在已经设置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中定义一个方法

转载于:https://www.cnblogs.com/jinkspeng/p/4015731.html

你可能感兴趣的文章