Ext中在每一个页面中添加一个namespace呢,就像下面的代码:
下面是Ext.nameSpace的API:
// create 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
下面是Ext.nameSpace的API:
namespace( String namespace1, String namespace2, String etc ) : void
Creates namespaces to be used for scoping variables and classes so that they are not global. Usage: Ext.namespace('C...
Creates namespaces to be used for scoping variables and classes so that they are not global. Usage:
Ext.namespace('Company', 'Company.data');
Company.Widget = function() { ... }
Company.data.CustomStore = function(config) { ... }
Parameters:
* namespace1 : String
* namespace2 : String
* etc : String
Returns:
* void
本文介绍如何在Ext中创建namespace来封装全局对象的属性和方法,避免与其他对象冲突,并提供了具体的代码示例。此外,还详细解释了Ext.namespace的用法及其参数。
244

被折叠的 条评论
为什么被折叠?



