当前位置: 首页 > 文档资料 > ExtJS 入门教程 >

Window

优质
小牛编辑
129浏览
2023-12-01

此UI组件用于创建一个窗口,该窗口应在发生任何事件时弹出。 窗口基本上是一个面板,当按钮/链接点击或悬停在任何事件时,它应该出现。

语法 (Syntax)

以下是创建窗口的简单语法。

win = new Ext.Window({ properties });

例子 (Example)

以下是显示电子邮件窗口的简单示例。

<!DOCTYPE html>
<html>
   <head>
      <link href = "https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" 
         rel = "stylesheet" />
      <script type = "text/javascript" 
         src = "https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script>
      <script type = "text/javascript">
         Ext.onReady(function() {
            win = new Ext.Window ({
               title:'Email Window',
               layout:'form',
               width:400,
               closeAction:'close',
               target : document.getElementById('buttonId'),
               plain: true,
               items: [{
                  xtype : 'textfield',
                  fieldLabel: 'To'
               },{
                  xtype : 'textfield',
                  fieldLabel: 'CC'
               },{
                  xtype : 'textfield',
                  fieldLabel: 'BCC'
               },{
                  xtype : 'textfield',
                  fieldLabel: 'Subject'
               },{
                  xtype : 'textarea',
                  fieldLabel: 'Email Message'
               }],
               buttons: [{
                  text: 'Save Draft',
                  handler: function(){Ext.Msg.alert('Save Draft', 'Your msg is saved');}
               },{
                  text: 'Send',
                  handler: function(){Ext.Msg.alert('Message Sent', 'Your msg is sent');}
               },{
                  text: 'Cancel',
                  handler: function(){
                     win.close(); Ext.Msg.alert('close', 'Email window is closed');}
               }],
               buttonAlign: 'center',
            });
            Ext.create('Ext.Button', {
               renderTo: Ext.getElementById('buttonId'),
               text: 'Click Me',
               listeners: {
                  click: function() {
                     win.show();
                  }
               }
            });
         });
      </script>
   </head>
   <body>
      <p> Click the button to see window </p>
      <div id = "buttonId"></div>
   </body>
</html>