use*_*122 19 javascript internet-explorer-9 reactjs
我正在尝试将React与Internet Explorer 9一起使用,但即使尝试运行非常准确的内容,也会出现以下错误:
SCRIPT438:对象不支持属性或方法'isArray'react-with-addons.js,第4行字符317
SCRIPT438:Object不支持属性或方法'create'JSXTransformer.js,第4行字符326
我读过https://facebook.github.io/react/docs/working-with-the-browser.html,其中说IE8可能有这些问题,但没有提及IE9.谷歌搜索也没有提出任何解决方案.
不过,我尝试按照该页面上的建议添加es5-shim/sham.这会导致不同的错误:
SCRIPT438:对象不支持属性或方法'hasAttribute'es5-shim.min.js,第6行字符4143
有没有人在IE9或其他之前遇到过这些错误?
谢谢您的帮助!
我正在尝试运行的完整代码是:
<html>
<head>
<script src="js/es5-shim.min.js"></script>
<script src="js/es5-sham.min.js"></script>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="js/react-with-addons.js"></script>
<script src="js/JSXTransformer.js"></script>
</head>
<body>
<div id="container"></div>
<script type="text/jsx">
React.render(
<h1>HELLO WORLD!</h1>
);
</script>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
mon*_*nic 40
一般您需要包含ES5功能的指定多边形填充(正如您所注意到的):https://facebook.github.io/react/docs/react-dom.html#browser-support您可能还需要HTMl5 shiv in除了您提供的poly-fill之外.
更具体地说,尽管问题可能不在于poly填充,但是文档模式IE9正在运行.您要确保在HTML文件中设置正确的文档模式,以便IE知道要定位的版本.否则,即使您使用的是IE9,也可能是针对IE7,这并不好.
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Run Code Online (Sandbox Code Playgroud)
在index.js文件中,您必须添加polyfill。这些导入应该在您的导入的第一个中。
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/ie11';
//other imports
Run Code Online (Sandbox Code Playgroud)
现在在您打开,即可以正常工作。
导入之前,您必须安装react-app-polyfill。
//To install use below command:
npm install react-app-polyfill
Run Code Online (Sandbox Code Playgroud)
链接参考:https : //www.npmjs.com/package/react-app-polyfill
| 归档时间: |
|
| 查看次数: |
40423 次 |
| 最近记录: |