Charles Zhang
Charles Zhang

Reputation: 115

Displaying an image in elm view

I'm having a lot of issues displaying images in elm. Whenever I do something like this, I would get this error enter image description here.

view : Model -> Html Msg  
view model =
        [img [src  "Img1.png"], width 300, height 300 ]

What I want to give a Html Msg that will display an image posx 0 posy 0 width 300 height 300 source "./Img1.png"

Upvotes: 2

Views: 5561

Answers (1)

Dogbert
Dogbert

Reputation: 222158

You have some brackets in the wrong place and a missing [] at the end. The code should be:

view model =
    img [src "Img1.png", width 300, height 300] []

So there's no [ the start because you need to return an HTML node, all the attributes go in in the second list, and there should be an empty list at the end for img elements.

Upvotes: 5

Related Questions