Javascript 限制在ExtJS Textarea中输入的行数

Javascript 限制在ExtJS Textarea中输入的行数,javascript,jquery,extjs,extjs4.1,lodash,Javascript,Jquery,Extjs,Extjs4.1,Lodash,看看这个。如何限制允许在ExtJS TextArea中输入的行数。ExtJs是否提供了一些开箱即用的功能,或者我必须回答一些cusotm函数,如图所示 我正在使用ExtJS4.1 Ext.onReady(function () { Ext.create('Ext.window.Window', { height: 60, layout: 'anchor', minHeight: 60, width: 200,

看看这个。如何限制允许在ExtJS TextArea中输入的行数。ExtJs是否提供了一些开箱即用的功能,或者我必须回答一些cusotm函数,如图所示

我正在使用ExtJS4.1

Ext.onReady(function () {
    Ext.create('Ext.window.Window', {
        height: 60,
        layout: 'anchor',
        minHeight: 60,
        width: 200,
        items: [{

            grow: true,
            anchor: '100%',
            flex: 1,
            xtype: 'textareafield'
        }]
    }).show();
});

您可以使用
maxLength
以及
enforceMaxLength
属性:

Ext.onReady(function () {
    Ext.create('Ext.window.Window', {
        height: 60,
        layout: 'anchor',
        minHeight: 60,
        width: 200,
        items: [{
            grow: true,
            anchor: '100%',
            flex: 1,
            xtype: 'textareafield',
            maxLength: 5, // 5 is only used for demo purpose
            enforceMaxLength: true
        }]
    }).show();
});

它限制允许输入的字符数,但不限制用户允许输入的行数。然后您需要编写一个自定义函数。