Den*_*low 6 dart dart-js-interop
有没有办法call()从Dart 调用一个名为(在嵌套对象中)的JavaScript函数,还是必须等待call()可能会删除特殊处理的Dart 2.0 ?
我有一个JS代理:
@JS()
class SomethingFancy {
external String call();
}
Run Code Online (Sandbox Code Playgroud)
但是,由于call()可以将对象转换为函数,因此无法访问JS对象的函数.
如果可以,我会在Dart中更改方法的名称,但不支持package:js:
/// By default the dart name is used. It is not valid to specify a custom
/// [name] for class instance members.
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
Uncaught Error: NoSuchMethodError: method not found: 'call$0' (J.getSomethingFancy$1$x(...).call$0 is not a function)
如果该函数不存在,则错误如下所示:
Uncaught Error: NoSuchMethodError: method not found: 'callMe' (receiver.callMe is not a function)
同一个对象上的其他函数工作得很好.
您可以前缀call有JS$:
@JS()
class SomethingFancy {
external String JS$call();
}
Run Code Online (Sandbox Code Playgroud)
JS$ 可以用作前缀以允许访问与 dart 关键字冲突的 JS 名称。
| 归档时间: |
|
| 查看次数: |
292 次 |
| 最近记录: |