export const appendScriptReady = (url, onReadyCallback) => {
  const targetScript = document.createElement('script')
  targetScript.type = 'text/javascript'
  if (targetScript.readyState) { // IE 6,7,8
    targetScript.onreadystatechange = () => {
      if (targetScript.readyState === 'loaded' ||
        targetScript.readyState === 'complete') {
        targetScript.onreadystatechange = null
        onReadyCallback()
      }
    }
  } else { // Not IE
    targetScript.onload = () => {
      onReadyCallback()
    }
  }

  targetScript.src = url
  document.head.appendChild(targetScript)
}

 

相关文章:

  • 2022-12-23
  • 2022-03-05
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
猜你喜欢
  • 2021-07-26
  • 2022-12-23
  • 2021-05-22
  • 2021-08-29
  • 2021-11-18
  • 2021-12-24
相关资源
相似解决方案