[英]how to handle with nested objects from js in dart (new dart-js-interop)
我为 Outlook Office365 创建了插件,并使用他们的office.js
来从电子邮件中获取信息。
dart.js 示例:
js.context['Office']['context']['mailbox']['userProfile']['emailAddress']
或者
js.context['Office']['context']['mailbox']['item']['to'].callMethod('getAsync', [callback(result)])
我如何使用新的dart-js-interop来满足此类需求?
@JS('Office.context.mailbox.userProfile.emailAddress')
external get emailAddress;
@JS('Office.context.mailbox.item.to.getAsync')
external getAsync(Function callback);
当您调用getAsync
您需要使用allowInterop
或allowInteropCaptureThis
包装您传递给回调的函数
getAsync(allowInterop((x) => print(x)));
谨慎尝试。 几个月前,我对新的 dart-js-interop 进行了一些尝试,但我自己还没有在实际代码中使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.