如何在Elm中编写以下标记?
<p>Here is <span class="red">some text.</span></p>
不完全是我想要的,但是一种解决方案是也将跨度放在其他文本上。
someText : Html Msg
someText =
p []
[ span [] [ text "Here is " ]
, span [ class "red" ] [ text "some text." ]
]
您可以简单地做到这一点:
p []
[ (text "hi there, ")
, span [] [ text "I'm a span" ]
]
这将创建HTML
<p>hi there, <span>I'm a span</span></p>
请参见Ellie处的运行示例。
确切的答案似乎只是前两个答案中的一部分
someText : Html Msg
someText =
p []
[ text "Here is "
, span [ class "red" ] [ text "some text." ]
]