0

StateSnapshot 示例中的主要组件不使用后端,但我需要一个。我的尝试:

class MainBackend($ : BackendScope[Unit, Name]) {
  def render(name: Name) = {
    val firstNameV = StateSnapshot.zoomL(Name.firstName).of(name)
    val surnameV = StateSnapshot.zoomL(Name.surname).of(name)
    <.div(
      <.label("First name:", NameChanger(firstNameV)),
      <.label("Surname:", NameChanger(surnameV)),
      <.p(s"My name is ${name.surname}, ${name.firstName} ${name.surname}.")
    )
  }
}

val Main = ScalaComponent
  .builder[Unit]("StateSnapshot example")
  .initialState(Name("John", "Wick"))
  .renderBackend[MainBackend]
  .build

value firstName is not a member of object app.TreeView.Name我在行中得到编译错误val surnameV = StateSnapshot.zoomL(Name.surname).of(name)

4

1 回答 1

1

通过使用.setStateVia($)不是.of($).

于 2017-08-14T09:33:29.940 回答