简体   繁体   English

如何让 Chrome 在没有 jQuery 的情况下在脚本标签上触发 load/onload 事件

[英]How to make Chrome fire the load/onload event on a script tag without jQuery

Problem: Chrome not firing load/onload on script elements.问题:Chrome 没有在脚本元素上触发加载/加载。 The issue has been mentioned previously in,这个问题之前已经提到过,

Chrome not properly observing onload event on script tags? Chrome 没有正确观察脚本标签上的 onload 事件?

Trying to fire the onload event on script tag 试图在脚本标签上触发 onload 事件

It looks like a proper answer hasn't been given about how to make it happen without jQuery.似乎没有给出关于如何在没有 jQuery 的情况下实现它的正确答案。

Im using somting like this in script and it works ok.我在脚本中使用这样的 somting,它工作正常。

 const url = `https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js` const script = document.createElement('script'); script.async = true; script.onload = () => console.log("script loaded") script.src = url; document.head.appendChild(script)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM