Ext.create()方法浅析

译自:http://docs.sencha.com/extjs/4.2.0/#!/api/Ext-method-create

[name], [args] ) :  Object

Instantiate a class by either full name, alias or alternate name.

If Ext.Loader is enabled and the class has not been defined yet, it will attempt to load the class via synchronous loading.

For example, all these three lines return the same result:

 // alias
 var window = Ext.create('widget.window', {
     width: 600,
     height: 800,
     ...
 });

 // alternate name
 var window = Ext.create('Ext.Window', {
     width: 600,
     height: 800,
     ...
 });

 // full class name
 var window = Ext.create('Ext.window.Window', {
     width: 600,
     height: 800,
     ...
 });

 // single object with xclass property:
 var window = Ext.create({
     xclass: 'Ext.window.Window', // any valid value for 'name' (above)
     width: 600,
     height: 800,
     ...
 });

Available since: 3.4.0

Parameters

  • name : String (optional)

    The class name or alias. Can be specified as xclass property if only one object parameter is specified.

  • args : Object... (optional)

    Additional arguments after the name will be passed to the class' constructor.

Returns

//

通过指定的名称 实例化一个类,其中第二个参数 中的 键值对 为 构造器 提供 实例化 时对应的参数名和值。

Ext.create()和Ext.()的区别:

Ext.widget

[name], [config] ) :  Object

Convenient shorthand to create a widget by its xtype or a config object. See also Ext.ClassManager.instantiateByAlias.

 var button = Ext.widget('button'); // Equivalent to Ext.create('widget.button');

 var panel = Ext.widget('panel', { // Equivalent to Ext.create('widget.panel')
     title: 'Panel'
 });

 var grid = Ext.widget({
     xtype: 'grid',
     ...
 });

If a component instance is passed, it is simply returned.

Available since: 4.0.0

Parameters

  • name : String (optional)

    The xtype of the widget to create.

  • config : Object (optional)

    The configuration object for the widget constructor.

Returns

/

可以通过别名访问 组件:

如下:

Ext.define('cdkj.view.correct.end.CorrectionEndListView',{
extend : 'Ext.grid.Panel',
alias : 'widget.correctCorrectionEndListView',
store : 'correct.CorrectionEndStore',
layout : {
type : 'fit'
},
title : '归档档案列表',

这时我们可以通过:

var view= Ext.widget("correctCorrectionEndListView");

创建一个cdkj.view.correct.end.CorrectionEndListView类的实例。





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值