let script = document.createElement('script'); script.src="https://code.jquery.com/jquery-3.2.1.min.js"; script.integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="; script.crossorigin="anonymous"; document.head.appendChild(script);
我尝试了一下,去掉integrity和crossorigin属性,就不再报CORS了...
如下:
let script = document.createElement('script'); script.src="https://code.jquery.com/jquery-3.2.1.min.js"; document.head.appendChild(script);
一个是本地文件,一个是 浏览器的临时文件。
在线加载的吧