【问题标题】:Vuetify dialog with iframe使用 iframe 进行 Vuetify 对话框
【发布时间】:2020-06-17 12:07:39
【问题描述】:

我的 Vue 应用程序包含嵌套在 Vuetify 对话框中的 iframe,我正在构建一个方法,该方法将通过 postMessage 将一些数据发送到 iframe,然后将弹出对话框,将显示带有所需数据的 iframe(在我的情况下 - 图像) 我的问题是在弹出对话框之前我无法指向 iframe 元素。

这是带有 iframe 的对话框:

<v-dialog
  v-model="editBoardDialog"
>
  <v-card>
      <!-- HERE -->
      <iframe id="ifrm" src="/ami.html" width="500" height="500"></iframe>
  </v-card>
</v-dialog>

这些是通过 postMessage 将图像发送到 iframe 并弹出对话框的方法

//opens the dialog
openEditor() {
    this.editBoardDialog = true 
    this.sendImageToIframe() //
},
//passing data to iframe
sendImageToIframe() {
    let iframe = document.getElementById("ifrm").contentWindow; //return NULL... why?
    //sends the image to the iframe
    iframe.postMessage({action:"updateAll",data:this.board.editorDetails})
}

【问题讨论】:

  • 对话框内容最初在 DOM 中不存在。只有在第一次打开时才会被注入。之后就可以继续查询了

标签: vue.js iframe vuetify.js postmessage


【解决方案1】:

试试这个https://vuetifyjs.com/en/api/v-dialog/#eager

<v-dialog eager v-model="editBoardDialog">
  <v-card>
    <!-- HERE -->
    <iframe id="ifrm" src="/ami.html" width="500" height="500"></iframe>
  </v-card>
</v-dialog>

【讨论】:

    猜你喜欢
    • 2020-09-10
    • 1970-01-01
    • 2022-11-25
    • 2013-01-12
    • 1970-01-01
    • 2021-11-04
    • 2020-09-19
    • 2020-07-25
    • 2011-12-28
    相关资源
    最近更新 更多