![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
//
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
Ext.onReady(function()
{
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
var _panel=new Ext.Panel(
{
renderTo:Ext.getBody(),
title:"XXX"
});
});空面板 加按钮
方法:addButton(String/Object _config,Function _handler,Object _scope):添加一个按钮对象到面板
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
var load=function(){
var _panel=new Ext.Panel({
title:"XXX",
frame:true,
width:300,
width:400
});
_panel.addButton({text:"确定",minWidth:100});
_panel.addButton(new Ext.Button({text:"取消"}));
_panel.render(Ext.getBody());//必须放这 放构造方法里后面的addButton方法无效
}
Ext.onReady(load);![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
引用Ext文件
<script type="text/javascript">
//panel form 布局
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
Ext.onReady(function()
{
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
var _panel=new Ext.Panel(
{
renderTo:Ext.getBody(),
layout:"form",
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
listeners:
{
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
"render":function(_panel)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
_panel.add(new Ext.form.TextField(
{
id:"txt",
labelWidth:10,
fieldLabel:"姓名"
})
);}
}
});
//render:当前对象正确构造后触发
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
new Ext.Button(
{
text:"确定",
renderTo:Ext.getBody(),
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
handler:function()
{
alert(Ext.getCmp("txt").getValue());
}
//句柄 默认click事件
//listeners:{"click",function(){}
//}
});
});
</script>