ExtJS 4.2 textfield 用两种颜色设置文本

有没有办法在文本字段中插入下一个值:

随机 (1234)

但在文本字段中将其可视化如下:

http://img2.mukewang.com/63523e0d00014e4b01340030.jpg

因为我从服务器检索信息如下:

"property1" : "Random (<span style='color:red;'>1234</span>)

文本字段位于表单内,当我检索用于loadRecord将数据加载到表单中的信息时。


绝地无双
浏览 229回答 1
1回答

守着一只汪

恕我直言,不可能使用“Ext.form.field.Text”来显示彩色文本。但是您可以使用显示字段(只读)或 html 编辑器..new Ext.panel.Panel({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title: 'Form',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renderTo: Ext.getBody(),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width: 550,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height: 250,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frame: true,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout: 'form',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; items: [{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xtype: 'htmleditor',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel: "HTML Editor",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; enableColors: false,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; enableAlignments: false,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value: "Random (<span style='color:red;'>1234</span>)",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }, {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xtype: 'displayfield',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel: "Display Field",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value: "Random (<span style='color:red;'>1234</span>)",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }]&nbsp; &nbsp; &nbsp; &nbsp; });
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript