【问题标题】:ExtJS 4.2 textfield set text with two coloursExtJS 4.2 textfield 用两种颜色设置文本
【发布时间】:2020-06-29 09:02:40
【问题描述】:

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

随机 (1234)

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

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

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

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

【问题讨论】:

    标签: javascript extjs extjs4.2


    【解决方案1】:

    恕我直言,不可能使用“Ext.form.field.Text”来显示彩色文本。 但您可以使用显示字段(只读)或 html 编辑器..

    new Ext.panel.Panel({
                title: 'Form',
                renderTo: Ext.getBody(),
                width: 550,
                height: 250,
                frame: true,
                layout: 'form',
                items: [{
                    xtype: 'htmleditor',
                    fieldLabel: "HTML Editor",
                    enableColors: false,
                    enableAlignments: false,
                    value: "Random (<span style='color:red;'>1234</span>)",
                }, {
                    xtype: 'displayfield',
                    fieldLabel: "Display Field",
                    value: "Random (<span style='color:red;'>1234</span>)",
                }]
            });
    

    【讨论】:

    • 好的,我试试这个解决方案
    猜你喜欢
    • 2020-08-26
    • 2021-01-22
    • 1970-01-01
    • 2019-04-10
    • 2016-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-07
    相关资源
    最近更新 更多