如何在 extjs6 中向文本表单字段添加工具提示

Val*_*or_ 1 javascript extjs extjs6

我有创建/渲染输入字段的功能,但我不知道如何在 EXTjs6 中添加工具提示

这是我的功能:

createInputField: function(value, fieldsMarginBottom, readonly) {
        var fieldStyle = this.getFieldStyle(readonly);
        var nameField = Ext.create('Ext.form.field.Text', {
            name: 'name',
            readOnly: true,
            hideLabel: true,
            value: value,
            width: this.fieldWidth,
            style: {
                marginBottom: fieldsMarginBottom + 'px'
            },
            //My try which is not working
            tooltip: {
                trackMouse: true,
                width: 140,
                renderer: function(tip, item){
                    tip.setTitle('name');
                    tip.update('Count: ');
                }
            },
            fieldStyle: fieldStyle
        });
        return nameField;
    }
Run Code Online (Sandbox Code Playgroud)

我希望你们能帮助我。如果您需要任何其他信息,请告诉我,我会提供。谢谢

Ale*_*der 5

从文档textfield可以看出,字段无法将工具提示添加到其配置中,因此您必须手动创建工具提示。

如果您查看文档以了解Ext.tip.ToolTip如何执行此操作,您可能会发现一个小示例,您只需根据配置描述更改target目标:

var tip = Ext.create('Ext.tip.ToolTip', {
    target: nameField.getEl(),
    html: 'Press this button to clear the form'
});
Run Code Online (Sandbox Code Playgroud)