5
Javascript에서 다트 함수를 호출하고 싶습니다.Javascript에서 다트 함수를 호출하는 방법은 무엇입니까?
나는 dart2js
(버전 1.1.3)을 사용하여 다트 함수를 포함하는 다트 스크립트를 컴파일 한 다음 생성 된 .js
파일을 자바 환경에로드하고이 함수를 자바 스크립트에서 호출하려고합니다.
Javascript의 myHyperSuperMegaFunction
을 (를) 호출하는 행에 뭔가가 있습니다.
import 'dart:js' as js;
int myHyperSuperMegaFunction(int a, int b) {
return a + b;
}
main() {
js.context['myHyperSuperMegaFunction'] = new js.JsFunction.withThis(myHyperSuperMegaFunction);
}
나는
dart2js
와 위를 컴파일하고 크롬으로 생성 된
.js
파일을로드했습니다. 변수
myHyperSuperMegaFunction
등록 내가 크롬 자바 스크립트 콘솔에서
myHyperSuperMegaFunction(2,3)
를 호출 할 때 나는
new js.JsFunction.withThis
을 사용하려면 필요하지 않은 다음과 같은 오류
NoSuchMethodError : method not found: 'Symbol("call")' Receiver: Instance of '(){this.$initialize' Arguments: [Instance of 'Window', 2, 3]