如何在 Ext.data.Model 中实现 getter 和 setter?
我的例子:
Ext.define('Person', {
extend: 'Ext.data.Model',
fields: [{
name: 'Name',
type: 'string'
}, {
name: 'Surname',
type: 'string'
}, {
name: 'BirthDate',
type: 'date',
dateFormat: 'd-m-Y'
}, {
name: 'Salary',
type: 'int'
}, {
name: 'Married',
type: 'boolean'
}],
convert: function (v, record) {
console.log(v)
return record.get('Surname') + v;
}
});
var person = Ext.create('Person', {
Name: 'Eugene',
Surname: 'Popov',
BirthDate: '22-05-1984',
Salary: 300,
Married: false
});
console.log(person.get('Salary')); //300
例如,我想要 person.get('Salary') 返回 300 美元。谢谢你的帮助。