ember.js:使用筆記5 使用view

來源:互聯網
上載者:User

標籤:blog   http   使用   ar   java   strong   sp   div   on   

在已經設定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中定義一個方法

ember.js:使用筆記5 使用view

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.