- Ext.js 教程
- Ext.js - 主页
- Ext.js - 概述
- Ext.js - 环境设置
- Ext.js - 命名约定
- Ext.js - 架构
- Ext.js - 第一个程序
- Ext.js - 类系统
- Ext.js - 容器
- Ext.js - 布局
- Ext.js - 组件
- Ext.js - 拖放
- Ext.js - 主题
- Ext.js - 自定义事件和侦听器
- Ext.js - 数据
- Ext.js - 字体
- Ext.js - 样式
- Ext.js - 绘图
- Ext.js - 本地化
- Ext.js - 可访问性
- Ext.js - 调试代码
- Ext.js - 方法
- Ext.js 实用资源
- Ext.js - 问答
- Ext.js - 快速指南
- Ext.js - 实用资源
- Ext.js - 讨论
Ext.js - 窗口
此 UI 组件用于创建一个窗口,该窗口应在发生任何事件时弹出。窗口基本上是一个面板,应该在任何事件(例如按钮/链接单击或鼠标悬停)发生时出现。
语法
下面是一个创建窗口的简单语法。
win = new Ext.Window({ properties });
示例
下面是一个显示电子邮件窗口的简单示例。
<!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>
上述程序将产生以下结果 -
extjs_components.htm
广告