2014-12-27 82 views
0

我有一個行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. 

如何調用該方法?

回答

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 

這意味着,對我來說,方法應該在uncurryied形式被調用,即

Dom_html.window##scroll(100, 100)