Ich möchte das Attribut html eines Elements in Elm kennen, zum Beispiel ihre Koordinaten. Ich habe es mit Json.Decode versucht.Ich möchte das Attribut html eines Elements in Elm kennen
Ich bin neu in Elm, und das ist für Lernzwecke.
Dies ist ein einfacher Code, ich bin mit Elm 0,18:
module Stamps exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
type alias Model =
{}
type Msg
= NoOp
| Clicking
model : Model
model =
{}
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
NoOp ->
(model, Cmd.none)
Clicking ->
let
_ =
Debug.log "msg1" model
in
(model, Cmd.none)
view : Model -> Html Msg
view model =
div
[ Html.Attributes.style
[ ("backgroundColor", "blue")
, ("height", "300px")
, ("width", "300px")
, ("position", "relative")
, ("left", "100px")
, ("top", "50px")
]
, Html.Attributes.class
"parent"
]
[ div
[ Html.Attributes.style
[ ("background-color", "#3C8D2F")
, ("cursor", "move")
, ("width", "100px")
, ("height", "100px")
, ("border-radius", "4px")
, ("position", "absolute")
, ("color", "white")
, ("display", "flex")
, ("align-items", "center")
, ("justify-content", "center")
]
, Html.Attributes.class
"children"
, Html.Events.onClick Clicking
]
[]
]
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
main : Program Never Model Msg
main =
Html.program
{ init = (model, Cmd.none)
, update = update
, view = view
, subscriptions = subscriptions
}