如何通过设备Android和iOS更改Xtype属性?



我使用Extjs6.0.2来创建项目,但现在我有问题,当我创建xtype: 'namefield',因为这种类型的xtype支持Android而不支持iOS设备,但是我希望我会找到解决方案,我怎么能通过使用这个来实现xtype。

lookupReference('txtPhoneNo').setConfig('xtype','numbercode')此代码替换为main.js

{
            xtype:'fieldset',
            items:[{
                minLength: 9,
                maxLength: 10, 
                xtype: 'textcode',
                cls: 'acledaTxt',
                itemId: 'txtPhoneNo',
                id: 'phonNo' ,
                reference: 'txtPhoneNo',
            }]
        },

不能更改组件的运行时类型

相反,您可以创建两个组件,并使用

隐藏或显示正确的组件
if (Ext.os.is.iOS) {
    // iPad, iPod, iPhone, etc.
}

或者你可以像这样动态地创建你的组件:

var xtype='';
if (Ext.os.is.iOS) {
    xtype='IOSXTYPE'
}else if(Ext.os.is.Android){
    xtype='AndroidXTYPE'
}
var component= Ext.create({
    xtype:xtype
});

最新更新