如何从Ext对象中删除属性?

gdrx4gfi  于 2022-09-26  发布在  其他
关注(0)|答案(2)|浏览(327)

如何从Ext对象中删除属性?例如:

Ext.define('Classes.Person', {status:'load',
    config: {
            name: 'Eugene',
            surname : 'Popov'
    },
    constructor: function(config) {
        this.initConfig(config);
    }
  });

var book = Ext.create('Classes.Person') 
/*
console.log(book.status)//load 
console.log( book.surname  )//Popov 
delete book.status
delete book.surname;
 console.log( book.surname  )//Popov 
 console.log(book.status)//load  How delete property ? 
 */

有没有特殊的方法来做到这一点?

vvppvyoh

vvppvyoh1#

删除属性的值而不是删除属性

console.log(book.status)//load 
console.log( book.surname  )//Popov 
book.status = undefined; //remove the existing value
book.surname = undefined;
console.log( book.surname  )//undefined 
console.log(book.status)//undefined
cxfofazt

cxfofazt2#

要从ExtJ中的对象中删除属性,只需使用“delete”命令,如示例所示:

delete book.status;

它从“book”对象中删除“status”属性。我刚刚检查了一下,效果很好。

相关问题