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)
。