zoukankan      html  css  js  c++  java
  • ember.js:使用笔记5 使用view

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

  • 相关阅读:
    CF 848C
    BZOJ 4025 二分图
    支配树学习笔记
    CF1120D Power Tree
    Codeforces 360A(找性质)
    Codeforces 142D(博弈)
    Codeforces 142B(二分染色、搜索)
    GYM 101981E(开关反转性质)
    Codeforces 1150E(树、线段树)
    Codeforces 1150D(字符串dp)
  • 原文地址:https://www.cnblogs.com/jinkspeng/p/4015731.html
Copyright © 2011-2022 走看看