callAsFunction 方法
- @JS('call')
使用 JavaScript 的 .call
语法调用此 JSFunction 并返回结果。
为了与其他 API 保持一致性和相对简洁性,最多接受 4 个参数。如果需要更多参数,您可以使用相同语法声明自己的外部成员。
实现
// We rename this function since declaring a `call` member makes a class
// callable in Dart. This is convenient, but unlike Dart functions, JavaScript
// functions explicitly take a `this` argument (which users can provide `null`
// for in the case where the function doesn't need it), which may lead to
// confusion.
// https://mdn.org.cn/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
@JS('call')
external JSAny? callAsFunction(
[JSAny? thisArg, JSAny? arg1, JSAny? arg2, JSAny? arg3, JSAny? arg4]);