(function(){
var DOC = document;
Ext.Element = function(element, forceNew){
.................
.................
}
var D = Ext.lib.Dom,
DH = Ext.DomHelper,
E = Ext.lib.Event,
A = Ext.lib.Anim,
El = Ext.Element,
EC = Ext.elCache;
El.prototype = {
name1:fn(){
},
name2:fn(){
}
.........
.........
}
})();这是Element对象在Extjs3.2中的模型,可以直接使用Ext.Element.name1();调用原型中的方法
而像这样:
(function() {
var goo=function(id){
alert("goo执行了");
};
goo.prototype={
ok:function(){
alert("ok执行了");
},
bye:function(){
alert("bye执行了");
}
}; })();
goo.ok();
提示goo未定义,这是怎么回事????
JavaScriptExt JS
var DOC = document;
Ext.Element = function(element, forceNew){
.................
.................
}
var D = Ext.lib.Dom,
DH = Ext.DomHelper,
E = Ext.lib.Event,
A = Ext.lib.Anim,
El = Ext.Element,
EC = Ext.elCache;
El.prototype = {
name1:fn(){
},
name2:fn(){
}
.........
.........
}
})();这是Element对象在Extjs3.2中的模型,可以直接使用Ext.Element.name1();调用原型中的方法
而像这样:
(function() {
var goo=function(id){
alert("goo执行了");
};
goo.prototype={
ok:function(){
alert("ok执行了");
},
bye:function(){
alert("bye执行了");
}
}; })();
goo.ok();
提示goo未定义,这是怎么回事????
JavaScriptExt JS
var goo=function(id){
alert("goo执行了");
};
goo.prototype={
ok:function(){
alert("ok执行了");
},
bye:function(){
alert("bye执行了");
}
};
window.goo = goo;
})();goo函数在红色函数内部,外部无法访问的
如果要访问,请加上蓝色部分代码
(function() {
fns.goo = function(id) {
//alert("goo执行了"); };
fns.goo.prototype = {
ok : function() {
alert("ok执行了");
},
bye : function() {
alert("bye执行了");
}
}; })();
var f=new fns.goo("dd");
f.ok();
这样就能访问goo的方法了了,但不使用new即 fns.goo.ok()提示:TypeError: fns.goo.ok is not a function
这又是怎么回事???
ok : function() {
alert("ok执行了");
},
你自己看阿