如何调用js_of_ocaml方法?

时间:2014-12-27 16:32:46

标签: ocaml js-of-ocaml

我有一个单行的js_of_ocaml程序:

Dom_html.window##scroll 100 100 ;

哪个失败并显示错误:

File "tests/test_scrolling.ml", line 2, characters 0-23:
Error: This expression has type int -> int -> unit Js.meth
       but an expression was expected of type < get : 'a; .. > Js.gen_prop
Command exited with code 2.

如何调用此方法?

1 个答案:

答案 0 :(得分:2)

根据documentation,方法调用具有以下语法:

        obj : <m : t_1 -> ... -> t_n -> u meth; ..> Js.t
            e_i : t_i               (1 <= i <= n)
        -------------------------------------------------
                  obj##m(e_1, ..., e_n) : u

这意味着,对我而言,应该以不受约束的形式调用这些方法,即

Dom_html.window##scroll(100, 100)