如何在榆树中呈现列表?

ond*_*rej 3 render list elm

我很难在视图函数中呈现自定义类型列表.这是模型:

type alias Guid = String
type alias User = String

type alias TaxonomyCategory =
  { id : Guid
  , name: String
  , updatedAt: Date
  , updatedBy: User
  , terms: List TaxonomyTerm
  }

type TaxonomyTerm =
  TaxonomyTerm
    { id : Guid
    , name: String
    , terms: List TaxonomyTerm
    }
Run Code Online (Sandbox Code Playgroud)

我尝试了几种使用List.map函数的方法,但我总是遇到某种错误消息.

The 2nd argument to function `ul` is causing a mismatch.

120|       ul
121|         []
122|>        [ List.map renderTaxonomyTerm tc.terms ]

Function `ul` is expecting the 2nd argument to be:

    List (VirtualDom.Node a)

But it is:

    List (List (Html a))
Run Code Online (Sandbox Code Playgroud)

Cha*_*ert 7

第二个参数ul应该是Html元素列表.您的第二个值包含列表中的列表,因为您用括号括起它.将其更改为此应解决您的问题:

ul
  []
  (List.map renderTaxonomyTerm tc.terms)
Run Code Online (Sandbox Code Playgroud)