Skip to content

[UIModel]formatters可否将执行scope指向当前model #33

@jinzhubaofu

Description

@jinzhubaofu

需求是想根据Model中的其他的数据,再来决定这个数据的格式。如果把formatter的执行Scope设定为当前Model,就可以类似这么干:

SomeModel.prototype.formatters = {
  someProperty: function (value) {
     return this.get('xxx') === 'xxx' ? null : new Date(value)
  }
};

这样就可以动态的格式化我的某个属性值了。或者有别的更好的解决办法,求指导。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions