Extjs4 API文档阅读--Ext.button.Button

来源:互联网 发布:最奇葩的淘宝差评有图 编辑:程序博客网 时间:2024/05/29 09:43

Ext.button.Buttonxtype: button

Create simple buttons with this component. Customisations include aligned icons, dropdown menus, tooltips and sizing options. Specify a handler to run code when a user clicks the button, or use listeners for other events such as mouseover. Example usage:

这个组件创建一个简单的按纽。可定制按纽的图标对齐方式,下拉菜单,工具提示和大小等选项。当用户点击按纽时将执行由处理程序(handler)指定的可执行代码,或使用监听器来捕获其它的事件,如鼠标悬停(mouseover)事例。用法示例:

Ext.create('Ext.Button', {    text: 'Click me',     // 按纽文本    renderTo: Ext.getBody(),   //渲染到哪里    handler: function() {         //单击执行的代码        alert('You clicked the button!')    }});

The handler configuration can also be updated dynamically using the setHandler method. Example usage:

处理程序的配置也可以使用setHandler方法动态更新的。用法示例:

Ext.create('Ext.Button', {    text    : 'Dynamic Handler Button',    renderTo: Ext.getBody(),    handler : function() {        // 此按钮每次你点击它会弹出不同的数字。        // 所以首先我们必须检查这个数字是否已经设置:        if (this.clickCount) {            // 如果这个属性已设置,所以我们给这个数字加1,并提醒用户            this.clickCount++;            alert('You have clicked the button "' + this.clickCount + '" times.\n\nTry clicking it again..');        } else {            // 如果这个 clickCount 属性示未设置, 我们将设置它并提醒用户            this.clickCount = 1;            alert('You just clicked the button for the first time!\n\nTry pressing it again..');        }    }});

A button within a container:

一个容器内的按钮:

Ext.create('Ext.Container', {    renderTo: Ext.getBody(),    items   : [        {            xtype: 'button',            text : 'My Button'        }    ]});

A useful option of Button is the scale configuration. This configuration has three different options:

一个有用的选项是Button的规模大小配置。这种配置有三个不同的选项:

  • 'small'
  • 'medium'
  • 'large'

Example usage: 用法示例:

Ext.create('Ext.Button', {    renderTo: document.body,    text    : 'Click me',    scale   : 'large'});

Buttons can also be toggled. To enable this, you simple set the enableToggle property to true. Example usage:

按钮也可以切换。您将enableToggle属性设置为true,可以非常简单的实现这样的效果。用法示例:

Ext.create('Ext.Button', {    renderTo: Ext.getBody(),    text: 'Click Me',    enableToggle: true});

You can assign a menu to a button by using the menu configuration. This standard configuration can either be a reference to a menu object, a menu id or a menu config blob. When assigning a menu to a button, an arrow is automatically added to the button. You can change the alignment of the arrow using the arrowAlign configuration on button. Example usage:

你可以使用menu选项给按纽指定一个菜单。标准配置是从下面两者之间任选一个引用到菜单对象,一个菜单ID或一个菜单配置项.当指定一个菜单到对象,按纽自动增加一个箭头.您可以使用arrowAlign配置更改按钮上的箭头对齐方式。用法示例:

Ext.create('Ext.Button', {    text      : 'Menu button',    renderTo  : Ext.getBody(),    arrowAlign: 'bottom',    menu      : [        {text: 'Item 1'},        {text: 'Item 2'},        {text: 'Item 3'},        {text: 'Item 4'}    ]});

Using listeners, you can easily listen to events fired by any component, using the listeners configuration or using the addListener method. Button has a variety of different listeners:

使用监听器,您可以使用监听器配置或使用addListener方法,轻松监听任何组件的事件。按钮具有各种不同的监听器:

  • click
  • toggle
  • mouseover
  • mouseout
  • mouseshow
  • menuhide
  • menutriggerover
  • menutriggerout

Example usage: 用法示例:

Ext.create('Ext.Button', {    text     : 'Button',    renderTo : Ext.getBody(),    listeners: {        click: function() {            // this == the button, 因为我们是在局部范围内            this.setText('I was clicked!');        },        mouseover: function() {            // 如果先前未设置,设置一个新的配置并提醒             if (!this.mousedOver) {                this.mousedOver = true;                alert('You moused over a button!\n\nI wont do this again.');            }        }    }});

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 皮质鞋子破皮了怎么办 吃了蜘蛛丝会怎么办 南京高二分班不公平怎么办? 高中分班考试没考好怎么办 实木门上的伸缩缝太深怎么办 mac点关机没反应怎么办 被压倒扁的易拉罐怎么办 白色车漏底漆了怎么办 客厅对着卧室门怎么办 老公不上进还懒怎么办 二胡按弦手指分不开怎么办 酷塑做完后疼痛怎么办 冷冻治疗后水泡破了怎么办 冷冻治疗的水泡破了怎么办? 冷冻治疗水泡破了怎么办 脚上冷冻后起泡怎么办 刺猴冷冻后起泡怎么办 隔壁太吵怎么办阴招 楼上有小孩太吵怎么办 捷达小水管睹了怎么办 楼房下水管冻了怎么办 一楼地面很潮湿怎么办 新房子地面有裂缝怎么办 地砖下面的下水管漏水怎么办 速冻饺子冻在一起了怎么办 牛排泡水解冻了怎么办 饺子都粘一起了怎么办 把桃子放冷冻了怎么办 抖音小视频连不上网怎么办 网络视频连不上网怎么办 苹果8视频不清晰怎么办 乳疮腐烂还臭怎么办 冰箱肉腐烂很臭怎么办 指环扣松了怎么办视频 奇迹mu端游杀人了怎么办 奇迹最强者号找不着了怎么办 v领地退不了押金怎么办 全民奇迹sf钻石变负数怎么办 电脑上的新建没有了怎么办 火车上行李箱砸人怎么办 违建拆除后怎么办房产证