Snippets add import jQuery CORS

来源:4-5 使用 Snippets 来辅助 Debugging

精慕门5330565

2022-11-07 16:48

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回答

  • 精慕门5330565
    2022-11-07 16:59:42
    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);


Chrome DevTools开发者工具调试指南

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

17000 学习 · 21 问题

查看课程

相似问题