无法向按钮添加事件侦听器。 “缺少方法的论据......”

时间:2016-09-06 12:23:58

标签: scala scala.js

我有一个简单的Scala.js应用程序,并且由于某种原因得到错误“缺少方法onButtonClick(dom.MouseEvent)的参数”。

package main

import scalatags.JsDom.all._
import org.scalajs.dom.{MouseEvent, document}

import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport

object Main extends js.JSApp {

  val boxA = input(
    `type` := "text",
    placeholder := "trust"
  ).render
  val boxB = input(
    `type` := "text",
    placeholder := "citation"
  ).render
  val b = button(
    placeholder := "Calculate"
    //, onclick := onButtonClick
  ).render

  def main(): Unit = {
    document.body.appendChild(div(h1("Hello, world"), boxA, boxB, b).render)
    b.addEventListener("onclick", onButtonClick)
  }

  def onButtonClick(event: MouseEvent): Unit = {
    println("click")
    println(boxA.value)
    println(boxB.value)
  }

}

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您需要这样的显式eta扩展:var url = '@Url.RouteUrl("QuadrantData", new { unit = "(unit)", begdate = "(begdate)", enddate = "(enddate)", httproute = true })'