目前,我在我的代码中使用hls.js来播放 hls 流。原始代码是用 ECMA 版本 6 编写的,然后转译成 ECMA 5 并放在 dist 文件夹中(链接上方)。它在其他地方完美运行。
如果库中的函数,我不打算使用任何函数。我只是想包括它。在 IE8 上呈现它会导致语法错误。
是否可以将 js 文件转换为与 IE8 兼容的版本,或者我应该找到一种根本不包含该文件的方法?
编辑
在此之后,我尝试执行以下操作:
<html>
<h1> IE test new </h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-sham.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-sham.min.js"></script>
<script src="https://wzrd.in/standalone/es7-shim@latest"></script>
<script src="https://cdn.jsdelivr.net/hls.js/latest/hls.js"></script>
</html>
但是,它仍然在 IE8 上给出以下错误:
Expected identifier hls.js, line 320 character 31
编辑 2
我使用以下.babelrc
文件将其转换为es3
文件并修复了一些其他错误。
{
"presets": ["es3"],
"plugins": ["transform-es3-property-literals", "transform-es3-member-expression-literals"]
}
但是,现在我在IE8
.
Object doesn't support this property or method hls.js, line 1063 character 17
具体报错就行了Object.defineProperty
。似乎 IE 8 不支持该defineProperty
方法。有没有办法解决这个问题。`?