簡體   English   中英

如何從ExtJs中的輸入組件元素獲取值

[英]How to get value from input component element in ExtJs

這是我的代碼:

xtype: 'component',
autoEl: {
    html: '<input type="text">'
},
listeners: {
    render: function(_component) {
        _component.getEl().on('keyup', function(e) {
            console.log(_component.getValue());
        });
    }
}

如您所見,每次嘗試在輸入中按下鍵時,我都試圖輸出輸入的值。 但是,控制台輸出的錯誤為:“未捕獲的TypeError:對象[object Object]沒有方法'getValue'”

如何獲得此文本框的值?

認為最好以“ ExtJS”方式聲明事件。

xtype: 'panel',
items: [
    { xtype: 'textfield', id: 'inputtext' }
]

在您的控制器中:

onLaunch: function () {
    this.control({
        '#inputtext': {
            keyup: function(e) {
               console.log(e.getValue());
            }
        }
    });
}

我的想法是ExtJS並不真的喜歡我們直接與DOM混淆

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM