美文网首页
ts contentWindow err: ‘HTMLEleme

ts contentWindow err: ‘HTMLEleme

作者: chxuu | 来源:发表于2022-04-28 16:38 被阅读0次
    11111.jpg

    解决:

    // 1. 将contentWindow保存到变量
    const iWindow = (this.$refs.editorFrame as HTMLIFrameElement).contentWindow; // 此时的iWindow类型为 Window | null
    // 2. 将iWindow进行断言
    iWindow as Window
    
    // 完整代码
    getIframeWindow(): Window {
        const iFrame = (this.$refs.editorFrame as HTMLIFrameElement).contentWindow;
        return iFrame as Window
      }
    

    相关文章

      网友评论

          本文标题:ts contentWindow err: ‘HTMLEleme

          本文链接:https://www.haomeiwen.com/subject/stedyrtx.html