ExtJs3.2第二篇:书写格式

我通常是这样写的,感觉还好。

<script type="text/javascript">
//1.组件继承:命名空间——>重写属性——>注册组件
Ext.ns("your.name");
your.name.newComponentName = Ext.extend(Ext.form.ComboBox,{
		//需要默认的值,可以被覆盖
		displayField: 'yearName',
		valueField: 'yearCode',
		emptyText: '请选择..',
		mode: 'remote',
		editable: false,
		selectOnfocus: true,
		triggerAction: 'all',
		store: new Ext.data.JsonStore({
			url: '',
			fields: new Ext.data.Record.create([]),
			root: 'root',
			autoLoad: true
		})
});
//注册后 可以用xtype: '简称'来创建该组件
Ext.reg('简称',your.name.newComponentName);
</script>
<script type="text/javascript">
//2.写一个完整页面的套路: 命名空间——>主要代码——>执行代码
Ext.ns("your.name");
your.name.newComponent = function() {
	//可以定义变量
	var a;
	var b;
	//没有: 代码都在里面
	return {
			//最后init会被执行
			init : function() {
				//调用其它方法 方法名要加上前面的your.name.newComponent
				//要有组件的引用要注意先后顺序!
				your.name.newComponent.doPanel01();
				your.name.newComponent.doPanel02();
				your.name.newComponent.function01();
				your.name.newComponent.functino02();
			},
			doPanel01 : function() {
			
			},
			doPanel02 : function() {
			
			},
			function01 : function() {
			
			},
			function02 : funciton() {
			
			}
	}
}();
Ext.onReady(your.name.newComponent.init,your.name.newComponent);
</script>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值