【发布时间】:2017-03-27 10:05:17
【问题描述】:
在使用 Redux 时,存储应该是唯一的事实来源,并且没有冗余。假设商店的一部分代表有名字和年龄的人。传统面向对象编程中的 person 类可能看起来像这样:
class Person {
constructor(first, last, birthday) {
this.first = first;
this.last = last;
this.birthday = birthday;
get_fullname() { // ... //}
get_age() { // ... //}
}
但是,Redux 存储中的对象不允许使用方法。那么,这些“方法”应该在哪里实现呢?
【问题讨论】:
标签: javascript redux