智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/4b/4b0b61d8295838e23fc032f377e...

21 lines
568 B

const scripts = {}
export default function loadScript (globalName, src, callback) {
const globalObject = typeof globalName === 'string' ? window[globalName] : globalName
if (globalObject) {
callback()
return
}
let callbacks = scripts[src]
if (!callbacks) {
callbacks = scripts[src] = []
const script = document.createElement('script')
script.src = src
document.body.appendChild(script)
script.onload = function () {
callbacks.forEach(callback => callback())
delete scripts[src]
}
}
callbacks.push(callback)
}