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.
我有一个名为 blockers 的道具,它返回一个可观察的对象数组。这些对象包含“userId”。
如何返回包含这些用户 ID 的数组?
计算的可观察量可以帮助解决此类情况。确保您的组件被装饰为mobx-react @observer,这样它就会自动使 props 可观察。
mobx-react
@computed get userIds () { return this.props.blockers.map(blocker => blocker.userId) }