引用托管在 BitBucket 上的外部 JS 片段
Referencing external JS snippet hosted on BitBucket
当引用托管在 BitBucket 上的外部 JS 片段时,它不会被加载并且无法工作。
HTML:
<html>
<head>
<script src="https://bitbucket.org/!api/2.0/snippets/[PATH TO FILE]/files/test.js"></script>
</head>
<body></body>
</html>
JS:
alert("Hello World");
当相同的 JS 文件存储在本地时,它可以工作,但当托管在 BitBucket 上时,它不会。有什么想法吗?
会不会是 link 的长度有问题? - 它有 109 个字符长。
如果您查看 Web 控制台,您应该会看到类似如下的错误:
Refused to execute script from 'https://bitbucket.org/!api/2.0/snippets/path/here/files/test.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
您将无法像可靠的跨浏览器那样直接执行它。
当引用托管在 BitBucket 上的外部 JS 片段时,它不会被加载并且无法工作。
HTML:
<html>
<head>
<script src="https://bitbucket.org/!api/2.0/snippets/[PATH TO FILE]/files/test.js"></script>
</head>
<body></body>
</html>
JS:
alert("Hello World");
当相同的 JS 文件存储在本地时,它可以工作,但当托管在 BitBucket 上时,它不会。有什么想法吗?
会不会是 link 的长度有问题? - 它有 109 个字符长。
如果您查看 Web 控制台,您应该会看到类似如下的错误:
Refused to execute script from 'https://bitbucket.org/!api/2.0/snippets/path/here/files/test.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
您将无法像可靠的跨浏览器那样直接执行它。