Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道 Ember Data 属性可以具有 defaultValue 属性的默认值,但 Ember 模型是否支持这一点?如果是这样,怎么做?
它还不支持默认值。如果你真的需要使用 ember 模型并且仍然想要这个功能,你可以扩展你使用的适配器来处理它,或者如果你只在单个路由中使用模型,你可以在 afterModel 钩子中修复模型(我不' 不喜欢这个想法,因为如果你曾经在其他任何地方使用过那个模型,你就会被冲洗掉)。如果您不能使用 ember 数据,我可能会修改 ember 模型代码并提交 PR。对不起