为了账号安全,请及时绑定邮箱和手机立即绑定

Snippets add import jQuery CORS

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.

正在回答

1 回答

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);


1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Chrome DevTools开发者工具调试指南
  • 参与学习       17179    人
  • 解答问题       21    个

全面掌握 Chrome 浏览器开发者工具的各项功能。

进入课程

Snippets add import jQuery CORS

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号