react如何从外部状态获取内部状态

2025-04-27 02:12:26
推荐回答(1个)
回答1:

  1. 通过MobX来解决

  2. MobX 是一个简单、高效的前端状态管理脚本库。 根据文档,Just do something to the state and MobX will make sure your app respects the changes。

  3. var person = mobx.observable({

  4. firstName: 'Matt',

  5. lastName: 'Ruby',

  6. age: 37,

  7. fullName: function () {

  8. this.firstName + ' ' + this.lastName;

  9. }

  10. });