![](/img/trans.png)
[英]How to construct a js object and call its methods with js_of_ocaml?
[英]How to call a js_of_ocaml method?
我有一个单行的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.
我怎么称呼这个方法?
根据文档 ,方法调用具有以下语法:
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.