我们可以利用 Html.Lazy.lazy 精确标记 stateful element ,但不是像 Attribute.lazy 可以标记 stateful attribute . 这背后的理性是什么?
stateful element
Attribute.lazy
stateful attribute
type alias Model = { text : String, color : String } view model = div [ style "color" model.color ] [ lazy text model.text ]
阅读后 Elm lazy guide 再一次,我发现这是我自己对 Html.Lazy 真的很管用。下面显示如何标记模型,包括 stateful attribute .
type alias Model = { txt : String, color : String } viewStateful txt color = div [ style "color" color ] [ text txt ] view model = lazy2 viewStateful model.txt model.color