dingtalk-docs-cool-app
Version:
钉钉文档酷应用插件扩展 开发者初始化包
1 lines • 616 B
JavaScript
import{Exception}from"./types/error";export function loadScript(t,e){void 0===e&&(e={});var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("script");r.type=e.type||"text/javascript",r.async="async"in e&&!!e.async,r.src=t,setAttributes(r,e.attrs);var o=new Promise((function(t,e){r.onload=function(){this.onerror=null,this.onload=null,t()},r.onerror=function(){this.onerror=null,this.onload=null,e(new Exception("internal_error","Failed to load "+this.src))}}));return n.appendChild(r),o}function setAttributes(t,e){e&&Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}