Skip to content

propsInAttrs 的必要性 #51

@lifesinger

Description

@lifesinger
    // config 中的这些键值会直接添加到实例上,转换成 properties
    propsInAttrs: ['initElement', 'element', 'events'],

这里面的值,最开始是 element, events, model, template,初衷是提供一种简写方式:

this.element 等价 this.get('element')
this.model 等价 this.get('model')

是一种语法糖。后来因为发现 this.templatethis.model 实际上比较少用,所有在上次修改中去掉了。

今天 CR 代码,看到 events 还在,同时还增加了 initElement,再仔细回顾『初心』:

propsInAttrs 是一种简化书写的语法糖

越发觉得 propsInAttrs 是个糟糕的设计,是否应该直接都放到 attrs 里就好?

如果要保留的话,也仅保留 element 就行,让 this.element 等价 this.get("element"),同时在继承时,会自动处理好值的继承?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions