functional-programming - Elm - 输入类型复选框

标签 functional-programming frontend elm reactive

我正在尝试为输入设置 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/

相关文章:

forms - 如何在 Elm 中提交表单?

elm - 在MVCTodo的更新版本中替换Html.app

java - 仅使用 java.util 实现无需 "switch"和 "if"语句的类似开关构造的 Java 8 功能方法是什么

Scala 性能 : imperative vs functional style

list - 更快的置换生成器

javascript - 多个命名 View 未显示

jquery - React 中的软滚动顶升

reactjs - 如何从检查元素/源中隐藏我的源代码?

webpack - 在Webpack中编译多个Elm项目

clojure - 在 Clojure 中一次执行多次归约