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 });

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

      

  • 相关阅读:
    MyBatis学习总结——MyBatis快速入门
    Java网络socket编程详解
    java中导出EXCEL表格
    利用反射将xml转换为List<Object>
    Java中将xml转为List<实体类>
    JavaWeb | 之 | 角色管理的表结构设计和原理
    fastjson把对象转化成json避免$ref
    JSON解析(DATE)对象数据
    jstl中<c:forEach>的用法
    请求转发与请求重定向的区别
  • 原文地址:https://www.cnblogs.com/linxiong945/p/3986426.html
Copyright © 2011-2022 走看看