extjs中动态显示当前时间

 // 初始化一些变量
 var aWeek = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
 var currentTime = new Ext.Toolbar.TextItem('当前时间:'
   + new Date().format('Y-m-d H:i:s') + '  '
   + aWeek[new Date().getDay()]);

 // 定期更新时间
Ext.TaskMgr.start({
    run : function() {
     Ext.fly(currentTime.getEl()).update('当前时间:'
       + new Date().format('Y-m-d H:i:s') + '  '
       + aWeek[new Date().getDay()]);
    },
    interval : 1000
   });   

然后将currentTime放入到toolbar中即可,例如:

var north = new Ext.Panel({
   region:"north",
   // contentEl和autoHeight用来将top.html中图片嵌入到index.html中
   contentEl:"topDiv",
   autoHeight:true,
   margins : "0 0 0 0",// 一个panel的上右左下的边距
   border:false,
   bbar: ["北京欢迎您",
   '-',currentTime,
   "->",{
    text:"帮助",
    icon:"images/help.png",
    handler:sthHelp
   },"-",{
    text : "退出",
    icon : "images/exit.png",
    handler : function() {
     window.location.href="../logout.action";
    }
   }, '-','   ']
 });

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值