`
- 浏览:
202087 次
- 性别:
- 来自:
北京
-
1:支持命名空间
<
script type
=
"
text/javascript
"
>
//
定义一个命名空间
Ext.namespace(
"
Ext.wentao
"
);
//
在命名空间上定义一个类
Ext.wentao.helloworld
=
Ext.emptyFn;
//
创建一个类的实例
new
Ext.wentao.helloworld();
</
script
>
其中
Ext.wentao.helloworld
=
Ext.emptyFn;
等价于
Ext.wentao.helloworld
=
function()
{}
;
2:支持类实例属性
<
script type
=
"
text/javascript
"
>
Ext.namespace(
"
Ext.wentao
"
);
//
自定义一个命名空间
Ext.wentao.Person
=
Ext.emptyFn;
//
在命名空间上自定义一个类
//
为自定义的类 增加一个 name 属性,并赋值
Ext.apply(Ext.wentao.Person.prototype,
{
name:
"
刘文涛
"
}
)
var _person
=
new
Ext.wentao.Person();
//
实例化 自定义类
alert(_person.name);
_person.name
=
"
张三
"
;
//
修改类name属性
alert(_person.name);
</
script
>
3:支持类实例方法
<
script type
=
"
text/javascript
"
>
Ext.namespace(
"
Ext.wentao
"
);
//
自定义一个命名空间
Ext.wentao.Person
=
Ext.emptyFn;
//
在命名空间上自定义一个类
//
演示类实例方法
Ext.apply(Ext.wentao.Person.prototype,
{
name:
"
刘文涛
"
,
sex:
"
男
"
,
print:function()
{
alert(String.format(
"
姓名:{0},性别:{1}
"
,
this
.name,
this
.sex));
}
}
)
var _person
=
new
Ext.wentao.Person();
//
实例化 自定义类
_person.print();
</
script
>
4:支持类静态方法
<
script type
=
"
text/javascript
"
>
Ext.namespace(
"
Ext.wentao
"
);
//
自定义一个命名空间
Ext.wentao.Person
=
Ext.emptyFn;
//
在命名空间上自定义一个类
//
演示类实例方法
Ext.apply(Ext.wentao.Person.prototype,
{
name:
"
刘文涛
"
,
sex:
"
男
"
,
print:function()
{
alert(String.format(
"
姓名:{0},性别:{1}
"
,
this
.name,
this
.sex));
}
}
)
//
演示 类静态方法
Ext.wentao.Person.print
=
function(_name,_sex)
{
var _person
=
new
Ext.wentao.Person();
_person.name
=
_name;
_person.sex
=
_sex;
_person.print();
//
此处调用类 实例方法,上面print是类 静态方法
}
Ext.wentao.Person.print(
"
张三
"
,
"
女
"
);
//
调用类 静态方法
</
script
>
5:支持构造方法
<
script type
=
"
text/javascript
"
>
Ext.namespace(
"
Ext.wentao
"
);
//
自定义一个命名空间
//
构造方法
Ext.wentao.Person
=
function(_cfg)
{
Ext.apply(
this
,_cfg);
}
//
演示类实例方法
Ext.apply(Ext.wentao.Person.prototype,
{
print:function()
{
alert(String.format(
"
姓名:{0},性别:{1}
"
,
this
.name,
this
.sex));
}
}
)
//
演示 类静态方法
Ext.wentao.Person.print
=
function(_name,_sex)
{
var _person
=
new
Ext.wentao.Person(
{name:_name,sex:_sex}
);
_person.print();
//
此处调用类 实例方法,上面print是类 静态方法
}
Ext.wentao.Person.print(
"
张三
"
,
"
女
"
);
//
调用类 静态方法
</
script
>
6:支持类继承
<
script type
=
"
text/javascript
"
>
Ext.namespace(
"
Ext.wentao
"
);
//
自定义一个命名空间
//
*******************父类*********************
//
构造方法
Ext.wentao.Person
=
function(_cfg)
{
Ext.apply(
this
,_cfg);
}
//
演示类实例方法
Ext.apply(Ext.wentao.Person.prototype,
{
job:
"
无
"
,
print:function()
{
alert(String.format(
"
姓名:{0},性别:{1},角色:{2}
"
,
this
.name,
this
.sex,
this
.job));
}
}
)
//
*******************子类1*********************
Ext.wentao.Student
=
function(_cfg)
{
Ext.apply(
this
,_cfg);
}
Ext.extend(Ext.wentao.Student,Ext.wentao.Person,
{
job:
"
学生
"
}
)
var _student
=
new
Ext.wentao.Student(
{name:
"
张三
"
,sex:
"
女
"
}
);
_student.print();
//
调用 父类方法
</
script
>
7:支持类实例方法重写
<
script type
=
"
text/javascript
"
>
Ext.namespace(
"
Ext.wentao
"
);
//
自定义一个命名空间
//
*******************父类*********************
//
构造方法
Ext.wentao.Person
=
function(_cfg)
{
Ext.apply(
this
,_cfg);
}
//
演示类实例方法
Ext.apply(Ext.wentao.Person.prototype,
{
job:
"
无
"
,
print:function()
{
alert(String.format(
"
姓名:{0},性别:{1},角色:{2}
"
,
this
.name,
this
.sex,
this
.job));
}
}
)
//
*******************子类1*********************
Ext.wentao.Student
=
function(_cfg)
{
Ext.apply(
this
,_cfg);
}
//
重写父类的 实例 方法
Ext.extend(Ext.wentao.Student,Ext.wentao.Person,
{
job:
"
学生
"
,
print:function()
{
alert(String.format(
"
{0}是一位{1}{2}
"
,
this
.name,
this
.sex,
this
.job));
}
}
)
var _student
=
new
Ext.wentao.Student(
{name:
"
张三
"
,sex:
"
女
"
}
);
_student.print();
//
调用 父类方法
</
script
>
8:支持命名空间别名
<
script type
=
"
text/javascript
"
>
Ext.namespace(
"
Ext.wentao
"
);
//
自定义一个命名空间
Wt
=
Ext.wentao;
//
命名空间的别名
//
*******************父类*********************
//
构造方法
Wt.Person
=
function(_cfg)
{
Ext.apply(
this
,_cfg);
}
//
演示类实例方法
Ext.apply(Wt.Person.prototype,
{
job:
"
无
"
,
print:function()
{
alert(String.format(
"
姓名:{0},性别:{1},角色:{2}
"
,
this
.name,
this
.sex,
this
.job));
}
}
)
//
*******************子类1*********************
Wt.Student
=
function(_cfg)
{
Ext.apply(
this
,_cfg);
}
//
重写父类的 实例 方法
Ext.extend(Wt.Student,Ext.wentao.Person,
{
job:
"
学生
"
,
print:function()
{
alert(String.format(
"
{0}是一位{1}{2}
"
,
this
.name,
this
.sex,
this
.job));
}
}
)
var _student
=
new
Wt.Student(
{name:
"
张q三
"
,sex:
"
女
"
}
);
_student.print();
//
调用 父类方法
</
script
>
9:支持类别名
<
script type
=
"
text/javascript
"
>
Ext.namespace(
"
Ext.wentao
"
);
//
自定义一个命名空间
Wt
=
Ext.wentao;
//
命名空间的别名
//
*******************父类*********************
//
构造方法
Wt.Person
=
function(_cfg)
{
Ext.apply(
this
,_cfg);
}
PN
=
Wt.Person;
//
类别名
//
演示类实例方法
Ext.apply(PN.prototype,
{
job:
"
无
"
,
print:function()
{
alert(String.format(
"
姓名:{0},性别:{1},角色:{2}
"
,
this
.name,
this
.sex,
this
.job));
}
}
)
//
*******************子类1*********************
Wt.Student
=
function(_cfg)
{
Ext.apply(
this
,_cfg);
}
ST
=
Wt.Student;
//
重写父类的 实例 方法
Ext.extend(ST,PN,
{
job:
"
学生
"
,
print:function()
{
alert(String.format(
"
{0}是一位{1}{2}
"
,
this
.name,
this
.sex,
this
.job));
}
}
)
var _student
=
new
ST(
{name:
"
张q三
"
,sex:
"
女
"
}
);
_student.print();
//
调用 父类方法
</
script
>
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
extjs属性方法集中方便你查看学习,赶快来下载吧!学习extjs
Extjs中文文档,包含Extjs的基本语法和各个类的详细说明以及用法。
Extjs 中文API文档,有对Extjs相关API的中文说明
Extjs+Gride使用方法 Extjs Gride
extjs4.1 中文API
用于对Extjs开发的帮助文档API,学者可以通过帮助文档来了解Extjs中各个空间的属性,主要用来学习和使用的。
extjs中文api,提供实例extjs中文api,提供实例extjs中文api,提供实例extjs中文api,提供实例extjs中文api,提供实例extjs中文api,提供实例
绝对的ExtJS3.0中文API,本人在网上找了好久才找到的,在此奉献给大家!!解压后有30多兆!!
extjs3.3的中文文档
4、选择“ExtJS” 并点击“Add Library”然后在下拉条中选取“ExtJS”; 5、选择 “ExtJS”并点击“Add File”,然后在你的./ext-2.x/source目录中选取“ext.jsb” 文件; 6、设置新的ExtJS Profile,选中并点击...
ExtJS中文文档,很好,很强大!绝对值得一看哦!
EXTJS应用EXTJS应用EXTJS应用EXTJS应用EXTJS应用EXTJS应用
EXTJS4自学手册——EXT文件目录,本地加载文档,命名规范 EXTJS4自学手册——EXT基本方法、属性(onReady、define、create) EXTJS4自学手册——EXT基本方法、属性(apply、applyIf、constructor) EXTJS4自学手册...
ExtJs 实例+ExtJs中文教程 大量ExtJs的实例和目前最好的ExtJs中文教程,学习ExtJs的朋友可以参考一下
extjs资料extjs资料extjs资料extjs资料extjs资料
Extjs 中文文档 学习文档
extjs4.0 技术中文视频讲解,内容非常的全,而且讲的也不错,这是第一部分,里面有下载地址 可用迅雷... 第九讲:extjs4.0的core包和Ext类 第十讲:extjs4.0的util包 论坛地址是: http://www.uspcat.com/?fromuid=413
ExtJs4.2代码例子 ExtJS Window常用方法
extjs向action提交的方法,由Ext界面提交到action的两种方法,点击id为save的按钮时,执行loginFun函数。
Extjs4 API文档阅读(一)——类系统(Class System) Extjs4 API文档阅读(三)——布局和容器 Extjs4 API文档阅读(二)——MVC构架(上) Extjs4 API文档阅读(二)——MVC构架(下) Extjs4 API文档阅读(四)——Data ...