通过MobX来解决
MobX 是一个简单、高效的前端状态管理脚本库。 根据文档,Just do something to the state and MobX will make sure your app respects the changes。
var person = mobx.observable({
firstName: 'Matt',
lastName: 'Ruby',
age: 37,
fullName: function () {
this.firstName + ' ' + this.lastName;
}
});