我在本地的 9180 端口上有一个测试页面,它正在从另一个端口加载 JS 以模拟不同的域。
<html>
<head>
<script src="http://localhost:8080/myscript.js" integrity="jRIKARJybgWRWqQslhFC5boBExY7MBLvUpMWYpuXuL1sDqCCp2Gd"></script>
</head>
<body>
Testing SRI
</body>
myscript.js
alert('Hello');
在浏览器上运行此程序时,我在控制台上看到错误,但仍会触发警报
Error parsing 'integrity' attribute ('jRIKARJybgWRWqQslhFC5boBExY7MBLvUpMWYpuXuL1sDqCCp2Gd'). The hash algorithm must be one of 'sha256', 'sha384', or 'sha512', followed by a '-' character.
我错过了什么吗?或者由于本地浏览器允许执行脚本。