new Promise((resolve, reject) =>{
const setScript = document.createElement("script");
const head=document.head || document.getElementsByTagName('head')[0];
setScript.src="https://webapi.amap.com/maps?v=2.0&key="
setScript.type="text/javascript"
head.appendChild(setScript);
setScript.onload=()=>{
resolve(1)
}
setScript.onerror=(err)=>{
reject(err)
}
} )
js动态添加script
于 2022-12-07 16:42:33 首次发布