您的代码工作正常。您正在使用表单面板上的 getEl() 方法选择容器元素。 textarea 覆盖了您的面板,因此您可以在底部看到缓动效果。如果要突出显示字段,则必须使用 each 方法遍历表单字段:
Ext.application({
name: 'Fiddle',
launch: function() {
Ext.create('Ext.form.Panel', {
title: 'My Form',
id: 'myform',
renderTo: Ext.getBody(),
width: 500,
height: 250,
items: [{
xtype: 'textarea',
width: '100%',
hideLabel: true,
value: 'Some text'
},
{
xtype: 'textfield',
width: '100%',
hideLabel: true,
value: 'Some other text'
}],
buttons: [{
text: 'Highlight',
handler: function() {
Ext.getCmp('myform').getForm().getFields().each(function(field) {
field.inputEl.highlight("ffff9c", {
attr: "backgroundColor",
endColor: "ffc333",
easing: 'easeIn',
duration: 1000
});
});
}
}]
});
}
});
在这个工作示例中,您正在更改背景颜色。标准 css 类包含输入字段的背景图像,因此您必须在效果期间临时将其删除。这可以使用自定义 css 类来覆盖 background-image 属性。
希望对你有帮助