gpt4 book ai didi

ngxs - 次状态的注意事项?

转载 作者:行者123 更新时间:2023-12-01 22:42:36 27 4
gpt4 key购买 nike

我是一名新手,正在使用 ngxs。

在文档上 There are caveats to Sub States .

  • 这仅适用于嵌套对象,因此尝试在嵌套数组对象上创建存储将不起作用。
  • 子状态只能使用一次,重用意味着一些限制,这些限制会消除一些高值(value)的功能。如果您想重复使用它们,只需创建一个新状态并从中继承即可。

我相信我在一定程度上理解了第一点,但我没有完全理解第二点的含义。

有人能够对此进行扩展吗?

最佳答案

这意味着单个状态类不能是多个父类的子类。解决方法是通过扩展来创建新的状态。所以

@State({
name: 'foo' // you can't have another state with this name
})
class MyState1 {}

// so if you want to reuse the listeners and such from 'foo' you have to extend
@State({
name: 'bar'
})
class MyState2 extends MyState1 {}

关于ngxs - 次状态的注意事项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50261126/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com