2015-12-03 76 views
2

如何在Ext js中创建Ext.data.Model时将字段创建为字符串元素列表?如何在模型中创建字符串列表:Extjs

Ext.define('User', { 
    extend: 'Ext.data.Model', 
    fields: [ 
     {name: 'name', type: 'string'}, 
     {name: 'age', type: 'int', convert: null}, 
     {name: 'phone', type: 'string'}, 
     {name: 'alive', type: 'boolean', defaultValue: true} 
    ] 
}); 

回答

1

只排除类型:

Ext.define('User', { 
    extend: 'Ext.data.Model', 
    fields: [ 
     {name: 'foo'} 
    ] 
}); 

var o = new User({ 
    foo: ['a', 'b', 'c'] 
}); 
console.log(o.get('foo')); 
相关问题