1 /** 2 * 创建模型,设置id 3 */ 4 Ext.onReady(function(){ 5 Ext.define(‘Person‘,{ 6 extend:‘Ext.data.Model‘, 7 idProperty:‘personId‘, 8 fields:[ 9 {name:‘name‘,type:‘string‘}, 10 {name:‘age‘,type:‘int‘} 11 ] 12 }); 13 var person1 = new Person({ 14 personId:‘person1‘, 15 name:‘zhouhai‘, 16 age:12, 17 }); 18 var person2 = new Person({ 19 personId:‘person2‘, 20 name:‘zhouhai‘, 21 age:12, 22 }); 23 //这个地方还不能 直接的person.name 24 //person.set({name:‘hello‘}); 25 26 //alert(person.get(‘name‘)); 27 console.log(person1); 28 29 console.log(person2); 30 });
时间: 2024-10-12 16:01:40