558/5000
当我尝试将本地JavaScript文件的链接引用更改为GitHub原始版本时,我的测试文件停止工作。 错误是:
由于其MIME类型(文本/纯文本)不可执行,因此拒绝执行脚本,并且启用严格的MIME类型检查。
有没有办法来禁用这种行为,或者有一个服务,允许链接到GitHub原始文件?
工作代码:
<script src =“bootstrap-wysiwyg.js”> </ script>
非工作代码:
<script src =“https://raw.github.com/mindmup/bootstrap-wysiwyg/master/bootstrap-wysiwyg.js”> </ script>
rawgithub.com重定向到rawgit.com所以上面的例子现在是
http://rawgit.com/user/package/master/link.min.js
这里是一个很好的办法解决这一点,现在,通过使用rawgit.com。
步骤:
在GitHub上找到你的链接,然后点击文件的“Raw”版本。
复制网址,并链接到它。
更改raw.githubusercontent.com为rawgit.com(非生产)或 cdn.rawgit.com(生产)
例如:
http://raw.githubusercontent.com/user/repo/branch/file.js
使用此URL进行开发:
http://rawgit.com/user/repo/branch/file.js
在制作中使用此网址:
http://cdn.rawgit.com/user/repo/tag/file.js
另请注意,对于生产环境,请考虑定位特定标