将 elm-ui 按钮附加到列的第二个子项,类型错误

发布于 2025-01-14 11:35:18 字数 847 浏览 0 评论 0原文

尝试在 elm 中创建一个简单的销售点,类似于下图。

单击一个产品(Input.button,它的类型是Element msg?),然后在订单列表面板中创建该按钮的记录。这也是一个Input.button,可以通过单击从“订单”面板中删除。

目前我的 model 看起来像这样:

type alias Orders =
    { order : Element Msg } -- fully aware this is uppercase 'M', not matching what the column expects

type alias Model =
    { orderlist : List Orders }

将我的 model 添加到 view .. column [] [ model.orderlist ]给出以下错误:

该参数是一个类型列表: 列表(列表订单)

但是 column 需要第二个参数为: 列表(元素消息)

我在这里缺少什么?欢迎任何评论或想法。此外,如果可以帮助我实现创建此 POS 的目标,我完全愿意走不同的方向。 TIA :)

“在此处输入图像描述"

Trying to create a simple Point of Sale in elm similar to image below.

Click a Product (Input.button, which understand is of type Element msg?) then a record of said button is created in the Order List panel. This is also an Input.button and can be removed from the Order panel by clicking.

At the moment my model looks like this:

type alias Orders =
    { order : Element Msg } -- fully aware this is uppercase 'M', not matching what the column expects

type alias Model =
    { orderlist : List Orders }

adding my model to view .. column [] [ model.orderlist ] gives the following error:

This argument is a list of type:
List (List Orders)

But column needs the 2nd argument to be:
List (Element msg)

what am I missing here? Any comments or ideas most welcome. Also I'm fully open to going a different direction if it might help me achieve my the goal of creating this POS. TIA :)

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唔猫 2025-01-21 11:35:18

正如错误消息所示,第二个参数应该是 Element msgList

但是您的 model.orderList 为您提供了一个记录列表 {order: Element Msg}

为了解决这个问题,您需要映射列表并提取您的 Element Msg,如下所示:

... column [] (model.orderList |> List.map (\{order} -> order))

As the error message says, it is expected that the 2nd argument would be a List of Element msg.

But your model.orderList gives you a List of a Record {order: Element Msg}.

In order to solve you will need to map on the list and extract your Element Msg, something like:

... column [] (model.orderList |> List.map (\{order} -> order))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文