判断iframe是否加载完成的完美方法

需求:vue某个组件引入iframe,需要判断iframe是否加载完毕,不然用户进入是白屏加载中

created (){
使用加载提示框
}
  mounted () {
    const iframe = document.querySelector('#iframe')
    // 处理兼容行问题
    if (iframe.attachEvent) {
      iframe.attachEvent('onload', () => {
        加载关闭提示框
      })
    } else {
      iframe.onload = () => {
       加载关闭提示框
      }
    }
  },
Logo

前往低代码交流专区

更多推荐