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);
error:
Subresource Integrity: The resource 'https://code.jquery.com/jquery-3.2.1.min.js' has an integrity attribute, but the resource requires the request to be CORS enabled to check the integrity, and it is not. The resource has been blocked because the integrity cannot be enforced.
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);