最简单的解决方案就是创建一个窗口。就像 Evan 在评论中所说的那样,MessageBox 只是一个 Ext.window.Window 宽度有点额外..
一个工作的fiddle
这是一个示例定义:
Ext.define('MyApp.view.Login', {
extend: 'Ext.window.Window',
height: 220,
width: 490,
layout: 'fit',
modal: true,
buttonAlign: 'left',
closable: false,
items: [
{
xtype: 'form',
frame: false,
border: 0,
layout: {
type: 'hbox',
align: 'middle'
},
fieldDefaults: {
msgTarget: 'side',
labelWidth: 55
},
items: [
{
xtype: 'container',
flex: 1,
padding: 10,
layout: {
type: 'vbox',
align: 'stretch'
},
items: [
{
xtype: 'textfield',
name: 'username',
fieldLabel: 'Username',
allowBlank: false,
flex: 1
},
{
xtype: 'textfield',
name: 'password',
fieldLabel: 'Password',
inputType: 'password',
allowBlank: false,
flex: 1
}
]
}
]
}
],
buttons: [
{
text: 'Login',
handler: function () {
Ext.Msg.alert('This is not yet implemented.').show();
}
}
]
});
然后你就可以创建并显示窗口了:
Ext.create('MyApp.view.Login').show();