将 elm-ui 按钮附加到列的第二个子项,类型错误
尝试在 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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如错误消息所示,第二个参数应该是
Element msg
的List
。但是您的
model.orderList
为您提供了一个记录列表{order: Element Msg}
。为了解决这个问题,您需要映射列表并提取您的
Element Msg
,如下所示:As the error message says, it is expected that the 2nd argument would be a
List
ofElement 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: