我正在尝试为输入设置 type
属性:
input [ type "checkbox" ] []
但是我收到一个错误:
It looks like the keyword `type` is being used as a variable. input [ type "checkbox" ] [] ^ Rename it to something else.
当我尝试使用时
input [ type' "checkbox" ] []
我收到此错误:
Ran into a single quote in a variable name. This was removed in 0.18! input [ type' "checkbox" ] [] ^ Change it to a number or an underscore, like type_ or type1 Or better yet, choose a more descriptive name!
如果我尝试
input [ type_ "checkbox" ] []
我收到另一个错误:
Cannot find variable `type_` input [ type_ "checkbox" ] [] ^^^^^
那么我最终如何设置这个属性呢?
最佳答案
正确的函数确实名为 type_
位于 Html.Attributes
模块中。确保您正确导入它。
-- this exposed type_, checked, and value (as examples)
import Html.Attributes exposing (type_, checked, value)
-- alternatively, to expose everything,
import Html.Attributes exposing (..)
关于functional-programming - Elm - 输入类型复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48997236/