ExtJS Button简单应用

本文介绍如何使用ExtJS创建一个包含下拉菜单的按钮组件。通过设置按钮的样式、大小及位置,并定义下拉菜单的内容。同时,文章展示了如何为按钮添加点击和鼠标悬停事件监听。

Ext.create("Ext.Button", {

               text: "click",    //文字
               renderTo: Ext.getBody(),    //页面展示
               height: 40,
               width: 100,
               style: { marginLeft: '100px' },   //样式

               //下拉效果
               arrowAlign: 'bottom',
               //下拉项
               menu: [
                       { text: 'Item 1' },
                       { text: 'Item 2' },
                       { text: 'Item 3' },
                       { text: 'Item 4' }
                    ],

               //添加事件侦听
               //具体事件:click toggle mouseover mouseout mouseshow menuhide menutriggerover menutriggerout
               listeners: {
                   click: function () {
                       //this == the button, as we are in the local scope
                       this.setText('I was clicked!');
                   },
                   mouseover: function () {
                       //set a new config which says we moused over, if not already set
                       if (!this.mousedOver) {
                           this.mousedOver = true;
                           alert('2');
                       }
                   }
               }

 

           })

转载于:https://www.cnblogs.com/Mr-Joe/archive/2012/02/21/2361079.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值