extjs怎么在toolbar中显示系统当前时间并不断刷新

2025-05-15 04:23:10
推荐回答(1个)
回答1:

tbar: [{
    xtype: 'label',
    width: 100,
    margins: {left: 10},
    id: 'clock',
    listeners: {
      'render': function() {
        clockGo();
      }
    }
},{},{}]
//---------------
function clockGo() {
  Ext.TaskManager.start({
    run: function() {
      Ext.getCmp("clock").setText(Ext.Date.format(new Date(), 'g:i:s A'));
    },
    interval: 1000
  });
}
//写的时候可能需要自定义一些样式,#clock{}

效果