【问题标题】:Unable to download Mustache.js file from CDN [duplicate]无法从 CDN 下载 Mustache.js 文件 [重复]
【发布时间】:2015-10-26 04:39:57
【问题描述】:

我正在尝试从 CDN 加载 mustache.js(无逻辑模板语言)作为外部文件,例如:

<script src="https://raw.githubusercontent.com/janl/mustache.js/master/mustache.min.js"></script>

但它给出了以下问题:

Refused to execute script from 'https://raw.githubusercontent.com/janl/mustache.js/master/mustache.min.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.

请帮助我。谢谢。

【问题讨论】:

    标签: javascript html handlebars.js mustache


    【解决方案1】:

    您尝试从中获取 mustache.js 文件的服务器配置为使用 Content-type: text/plain 提供文件,出于安全原因,我认为浏览器不会将其解释为 Javascript。我不确定您是否需要特定版本的 mustache.js,或最新版本的链接。在寻找其他 CDN 的托管小胡子时,我找到了以下对我有用的内容,并且根据您的要求可能对您有用:

    <script
    src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.1.3/mustache.js"></script>
    

    编辑:

    我发现实际上在 Github 上有一项服务可以提供更正的 MIME 类型。您为该服务编辑的链接如下:

    <script
    src="https://raw.githack.com/janl/mustache.js/master/mustache.min.js"></script>
    

    【讨论】:

      猜你喜欢
      • 2012-01-09
      • 1970-01-01
      • 2020-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-08
      • 2017-04-22
      相关资源
      最近更新 更多