gpt4 book ai didi

list - 如何在榆树中呈现列表?

转载 作者:行者123 更新时间:2023-12-01 09:50:51 26 4
gpt4 key购买 nike

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

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
}

我用 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))

最佳答案

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

ul
[]
(List.map renderTaxonomyTerm tc.terms)

关于list - 如何在榆树中呈现列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38060359/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com