定义:

 Ext.MessageBox.show({
   title: 'Please wait',
   msg: 'Loading items...',
   progressText: 'Initializing...',
   width:300,
   progress:true,
   closable:false
});

例子:

<!DOCTYPE html>
<html>
    <head>
        <link
            href="./ext-6.0.0-gpl/ext-6.0.0/build/classic/theme-classic/resources/theme-classic-all.css"
            rel="stylesheet"
        />
        <script src="./ext-6.0.0-gpl/ext-6.0.0/build/ext-all.js"></script>
        <script type="text/javascript">
            Ext.onReady(function () {
               function progressBar(v) {
                return function() {
                  if(v == 10) {
                    Ext.MessageBox.hide() //隐藏消息框
                    result()
                  } else {
                    var i = v/9
                    Ext.MessageBox.updateProgress(i, Math.round(100*i) + '% completed') //更新进度条
                  }
                }
               }
               function showProgressBar() {
                for(var i = 1; i < 11; i++) {
                  setTimeout(progressBar(i), i*500) //延迟执行,每500毫秒执行一次
                }
               }
               function result() {
                Ext.Msg.alert('status', 'Progress completed succesfully')
               }
               Ext.create('Ext.Button', {
                renderTo: Ext.getElementById('formID'),
                text: 'click me',
                listeners: {
                  click: function() {
                    Ext.MessageBox.show({
                      title: 'Please wait',
                      msg: 'Loading items...',
                      progressText: 'Initializing...',
                      width: 300,
                      progress: true, //显示进度条
                      closeable: false
                    })
                    showProgressBar() //显示进度条
                  }
                }
               })
            });
        </script>
    </head>
    <body>
        <div id="formID"></div>
    </body>
</html>

运行结果:
image.png


零号
1 声望0 粉丝