dart - 该文档不是WindowBase的成员

标签 dart

我正在更新旧代码,而这部分无效:

IFrameElement iframe = query('#myframe iframe');
Window iframeW = iframe.contentWindow;// cast error
var myframeDoc = iframeW.document; 

我将Window更改为“WindowBase”:

IFrameElement iframe = query('#myframe iframe');
WindowBase iframeW = iframe.contentWindow;
var myframeDoc = iframeW.document; 

但是document不是WindowBase的成员。
我想访问它来像这样查询:

    myframeDoc.query("#myId");

使用javascript,该解决方案适用:

var myframeDoc = document.querySelector('#myframe iframe').contentWindow.document;

最佳答案

iFrame和Windows的API略有不同,因此您必须使用WindowBase而不是Window

您可以在API文档中看到IFrameElement.contentWindow的类型是WindowBase,并且还应该在编辑器的弹出文档中看到它。

关于dart - 该文档不是WindowBase的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15444109/

相关文章:

dart - Flutter/flutter_webview_plugin => 在向下/向上滚动时隐藏/显示 AppBar + BottomNavigationBar

github - Dart pub.dev发布的插件,README.md中的图像损坏

ios - Flutter:iOS NavigationBar 过渡

dart - 带有可选参数的可选回调

flutter - 如何清理卸载flutter fvm包

flutter - 设置边框颜色使const变量必须使用常量值初始化

Dart : how can assign the result of httpRequest on a property object?

android - 获取可与 Cloud Firestore 配合使用的简单应用

firebase - 为什么此快照两次将每个文档获取两次? flutter

dart - 错误 : Only static members can be accessed in initializers what does this mean?