我正在学习Elm,完成教程后,我开始从头开始一个新的应用程序,但当我在视图中添加新的HTML标签时,我得到一个错误。
我的代码:
module Main exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
main : Html a
main =
span [ class "welcome-message" ] [ text "Hello, World!" ]
, h1 [class "headline"] [text "Hello"]错误:
Detected errors in 1 module.
-- SYNTAX PROBLEM -----------------------------------------------------
Main.elm I ran into something unexpected when parsing your code!
10| , h1 [class "headline"] [text "Hello"]
^ I am looking for one of the following things:
end of input
whitespace我在Windows 10上使用Visual Studio代码。
我的编辑器被配置为使用LF和4个空格的缩进。
我在PowerShell上使用elm-reactor。
发布于 2018-07-26 22:15:36
您的代码是无效的Elm代码:逗号只能在列表(或记录)的元素之间移动。此外,您不能在顶层有两个Html节点,因此需要将它们包装在单个元素中。在本例中,您可能希望将这两个文件包装在一个div [] []中
main : Html a
main =
div []
[ span [ class "welcome-message" ] [ text "Hello, World!" ]
, h1 [ class "headline" ] [ text "Hello" ]
]https://stackoverflow.com/questions/51540838
复制相似问题