React JS无法使用Internet Explorer 9 [英] React JS not working with Internet Explorer 9

查看:95
本文介绍了React JS无法使用Internet Explorer 9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将React与Internet Explorer 9一起使用,但即使尝试运行非常准确的内容也会出现以下错误:




SCRIPT438 :Object不支持属性或方法'isArray'
react-with-addons.js,第4行字符317



SCRIPT438:对象不支持属性或方法'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或其他之前遇到过这些错误?



感谢您的帮助!



我正在尝试运行的完整代码是:



< pre class =snippet-code-html lang-html prettyprint-override> < 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> < /头> <身体GT; < div id =container>< / div> < script type =text / jsx> React.render(< h1> HELLO WORLD!< / h1>); < /脚本> < / body>< / html>

解决方案

常规您需要为ES5功能包含指定的多边形填充(正如您所注意到的): https://facebook.github.io/react/docs/react-dom.html#browser-support 您可能还需要HTMl5 shiv以及你提供的多重填充。



更具体地说,尽管问题可能不是多边形填充,而是文件模式IE9正在运行。你想确保您正在HTML文件中设置正确的文档模式,因此IE知道要定位的版本。否则,即使您使用的是IE9,也可能是针对IE7,这是不好的。

 < meta http-equiv =X -UA-兼容content =IE = edge> 


I'm trying to use React with Internet Explorer 9 but getting the following errors even trying to run something very barebones:

SCRIPT438: Object doesn't support property or method 'isArray' react-with-addons.js, line 4 character 317

SCRIPT438: Object doesn't support property or method 'create' JSXTransformer.js, line 4 character 326

I've read https://facebook.github.io/react/docs/working-with-the-browser.html, which says IE8 might have these issues, but no mention about IE9. Googling didn't really bring up any solutions either.

Still, I tried adding es5-shim/sham as suggested on that page. That results in a different error:

SCRIPT438: Object doesn't support property or method 'hasAttribute' es5-shim.min.js, line 6 character 4143

Has anyone encountered these errors before in IE9 or otherwise?

Thanks for the help!

The full code I'm trying to run is:

<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>

解决方案

General You need to include the specified poly fills for ES5 features (as you've noticed): https://facebook.github.io/react/docs/react-dom.html#browser-support You may also need HTMl5 shiv in addition to the the poly-fills you've provided.

More specifically though the problem is probably not with poly fills but with the document mode IE9 is running in. You want to make sure that you are setting the correct document mode in your HTML file so IE, knows which version to target. Otherwise even though you are using IE9 it may be targeting IE7 which is no good.

<meta http-equiv="X-UA-Compatible" content="IE=edge">

这篇关于React JS无法使用Internet Explorer 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆