zoukankan      html  css  js  c++  java
  • 【ExtJS】关于alias和xtype

    alias

    在api里的解释为:别名 类名称简短的别名列表。多数用于定义xtypes

     1 Ext.define('MyApp.Panel', {
     2     extend: 'Ext.panel.Panel',
     3     alias: 'widget.mypanel',
     4     title: 'MyPanel'
     5 });
     6 
     7 Ext.onReady(function(){
     8     // 使用 Ext.create
     9     Ext.create('widget.mypanel',{
    10         html: 'Create Widget!',
    11          400,
    12         height: 200,
    13         broder: true,
    14         renderTo: Ext.getBody()});
    15 
    16     // 使用xtype
    17     Ext.widget('panel', {
    18         renderTo: Ext.getBody(),
    19          400,
    20         margin: '10 0 0 10 ',
    21         broder: true,
    22         items: [
    23             {xtype: 'mypanel', html: 'Xtype1!'},
    24             {xtype: 'mypanel', html: 'Xtyoe2!'}
    25         ]
    26     });
    27 
    28 
    29 });

    效果:

      不过我在5.0官方例子中,经常看到例子里很少用alias来表示类的别名,而是经常用xtype来表示

     1 Ext.define('MyApp.Panel', {
     2     extend: 'Ext.panel.Panel',
     3     //alias: ['widget.mypanel'],
     4     xtype: 'mypanel',
     5     title: 'MyPanel'
     6 });
     7 
     8 Ext.onReady(function(){
     9     // 使用 Ext.create
    10     Ext.create('widget.mypanel',{
    11         html: 'Create Widget!',
    12          400,
    13         height: 200,
    14         broder: true,
    15         renderTo: Ext.getBody()});
    16 
    17     // 使用xtype
    18     Ext.widget('panel', {
    19         renderTo: Ext.getBody(),
    20          400,
    21         margin: '10 0 0 10 ',
    22         broder: true,
    23         items: [
    24             {xtype: 'mypanel', html: 'Xtype1!'},
    25             {xtype: 'mypanel', html: 'Xtyoe2!'}
    26         ]
    27     });
    28 
    29 
    30 });

    效果是一样的,感觉这样比原来的更好记,更直观一些。

      

  • 相关阅读:
    Codeforces Round #239(Div. 2) 做后扯淡玩
    hdu 3507 Print Article
    prufer序列
    POJ 2778 DNA Sequence
    Codeforces Round #237 (Div. 2)
    poj3352
    图论知识
    POJ 2186
    Codeforces Round #236 (Div. 2)
    POJ 2823 Sliding Window
  • 原文地址:https://www.cnblogs.com/linxiong945/p/3986426.html
Copyright © 2011-2022 走看看