我一直在尝试几件事,并且无法解决如何使用 Bootstrap
设置此 Elm
表的样式,因此它是 striped . 我正在尝试使用elm-bootstrap并已安装 rundis/elm-bootstrap 4.1.0
Bootstrap.Table
目前尚未使用:
module Players.List exposing (..)
import Html exposing (..)
import Html.Attributes exposing (class)
import Msgs exposing (Msg)
import Models exposing (Player)
import RemoteData exposing (WebData)
import Bootstrap.Table as Table
view : WebData (List Player) -> Html Msg
view response =
div []
[ nav
, maybeList response
]
nav : Html Msg
nav =
div [ class "clearfix mb2 white bg-black" ]
[ div [ class "left p2" ] [ text "Players" ] ]
maybeList : WebData (List Player) -> Html Msg
maybeList response =
case response of
RemoteData.NotAsked ->
text ""
RemoteData.Loading ->
text "Loading..."
RemoteData.Success players ->
list players
RemoteData.Failure error ->
text (toString error)
list : List Player -> Html Msg
list players =
div [ class "col-md-4" ]
[ table [ class "table table-striped" ]
[ thead []
[ tr []
[ th [] [ text "Id" ]
, th [] [ text "Initials" ]
, th [] [ text "Time" ]
, th [] [ text "Score" ]
]
]
, tbody [] (List.map playerRow players)
]
]
playerRow : Player -> Html Msg
playerRow player =
tr []
[ td [] [ text player.id ]
, td [] [ text player.initials ]
, td [] [ text (toString player.time) ]
, td [] [ text (toString player.score) ]
]
因为这应该是非常简单的我在这里显然遗漏了一些东西 . 我怎样才能让这张桌子条纹化?
1 回答
您的示例使用来自Elm 's HTML library but you'的HTML函数可能会更好地使用适当的Bootstrap类型和函数 . 例如,使用table options defined in the documentation,您可以重写视图函数,如下所示:
这将为您提供正确的HTML,但您可能仍需要导入Bootstrap样式 . 文档提供了一个包含样式表的示例,您可以在某些包装函数中执行该示例表,例如:
这是slimmed down Ellie example to play with .