gpt4 book ai didi

f# - 此表达式应具有类型 'obj' 但此处具有类型 'string'

转载 作者:行者123 更新时间:2023-12-01 13:16:22 25 4
gpt4 key购买 nike

下面的代码有一个类型错误,比如“这个表达式应该有‘obj’类型,但这里有‘string’类型”

    let fiveDaysForecast (model: CityForecast) = 
let fiveDays = model.Days |> List.truncate 5
let city = if model.Country |> String.IsNullOrWhiteSpace then model.City else sprintf "%s, %s" model.City model.Country
View.StackLayout(padding = 20.0, verticalOptions = LayoutOptions.FillAndExpand,
children = [
View.Label(text=city.ToUpper(), textColor=Color.Beige, backgroundColor=Color.FromHex("#0F4D8FAC"), fontSize=40, fontAttributes=FontAttributes.Bold, horizontalTextAlignment=TextAlignment.Center)
empty 20.
View.Grid(
rowdefs=["*"],
coldefs=[ for _ in fiveDays -> "*" ],
children = (fiveDays |> List.mapi (day 0) ) )
])

这行代码的错误 coldefs=[ for _ in fiveDays -> "*"], 由于 "*"

我该如何解决?

最佳答案

根据 Fabulous Guide ( https://fsprojects.github.io/Fabulous/views-perf.html ),您需要将列表元素装箱:

coldefs=[ for _ in fiveDays -> box "*" ]

关于f# - 此表达式应具有类型 'obj' 但此处具有类型 'string',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54518079/

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