Ext.draw.Text 动态改变文字

Posted

技术标签:

【中文标题】Ext.draw.Text 动态改变文字【英文标题】:Ext.draw.Text dynamically change text 【发布时间】:2013-02-13 19:27:01 【问题描述】:

如何在 Ext.draw.Text 元素上动态更改文本?

this.textLabel = Ext.create "Ext.draw.Text"
        type  : 'text',
        text  : me.curValue,
        font  : '24px Arial',
        width : 100,
        height: 30,
        x : 100 
        y : 120

此方法无效:

   this.textLabel.setText("new text")

我该怎么做?

【问题讨论】:

【参考方案1】:

我不知道是不是错字,但你的代码应该是这样的:

this.textLabel = Ext.create('Ext.draw.Text', 
    type  : 'text',
    text  : me.curValue,
    font  : '24px Arial',
    width : 100,
    height: 30,
    x : 100, 
    y : 120
);

this.textLabel.setText("new text");

还有thisme 指的是什么?更多代码会有所帮助。 无论如何,这是一个工作示例:http://jsfiddle.net/6zczP/2/

【讨论】:

是的,问题出在组件的结构上,我将 Ext.draw.Text 添加为图表项,但它不能正常工作。感谢您的回答

以上是关于Ext.draw.Text 动态改变文字的主要内容,如果未能解决你的问题,请参考以下文章