Extjs中在每一个页面中添加一个namespace呢,就像下面的代码:
Ext.namespace('myNameSpace');
// create application
myNameSpace.app = function() {
// do NOT access DOM from here; elements don't exist yet
// private variables
// private functions
// public space
return {
// public properties, e.g. strings to translate
// public methods
init: function() {
alert('Application successfully initialized');
}
};
}(); // end of app
Extjs通过onReady调用color函数,init为color中的内置,作用是初始化.这种写法比较实用
<script>
Ext.color = function(){
return {
init:function(){
alert("init")
}
}
}();
Ext.onReady(Ext.color.init,Ext.color);
</script>
Extjs是面向对象
Ext.namespace("com.hawk");
com.hawk.First = function () {
//私有成员
var kiss = "中华人民共和国";
//私有方法
//公有方法
return {
//公有方法
init: function () {
alert("init");
alert(kiss);
},
//
method: function () {
alert("method");
}
};
};