目前,我在我的代码中使用hls.js来播放hls流。原始代码以ECMA版本6编写,然后转译成ECMA 5并放置在dist文件夹中(位于链接上方)。它适用于其他地方。在IE8中包含ECMA 5脚本
我不打算使用库中的任何函数。我只是想包括它。在IE8上渲染它会导致语法错误。
是否有可能将js文件转换成与IE8兼容的版本,或者我应该简单地找到一种不包含文件的方法?
编辑
继this我试着做以下几点:
<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/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/hls.js/latest/hls.js"></script>
</html>
但是,它仍然给出了IE8以下错误:
Expected identifier hls.js, line 320 character 31
EDIT 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
方法。有没有办法解决这个问题?
https://github.com/es-shims/es5-shim – Xotic750
https://www.typescriptlang.org/ –
@ Xotic750我试着用https://github.com/es-垫片/ es5-shim,它仍然给IE8上的错误。 (检查编辑) – user3288346