Javascript IE7对象中的Angularjs错误不';t支持属性或方法';查询选择器';
我在现有asp.net项目中引入angularjs,该项目中有许多语句仅在IE 7兼容模式下工作,但当我运行该项目时,我从angularjs文件中得到以下错误Javascript IE7对象中的Angularjs错误不';t支持属性或方法';查询选择器';,javascript,html,asp.net,angularjs,internet-explorer-7,Javascript,Html,Asp.net,Angularjs,Internet Explorer 7,我在现有asp.net项目中引入angularjs,该项目中有许多语句仅在IE 7兼容模式下工作,但当我运行该项目时,我从angularjs文件中得到以下错误 Object doesn't support property or method 'querySelector' 在对这个问题进行了一些研究和开发之后,我发现querySelector只是从IE8引入的 现在我如何使用angularjs使我的应用程序在IE7中工作 我不想为超过IE7设置meta标记,因为我现有的应用程序依赖于IE7,
Object doesn't support property or method 'querySelector'
在对这个问题进行了一些研究和开发之后,我发现querySelector只是从IE8引入的
现在我如何使用angularjs使我的应用程序在IE7中工作
我不想为超过IE7设置meta标记,因为我现有的应用程序依赖于IE7,而IE7在IE8及以上版本中不起作用
我尝试如下配置角度模块禁用SCE:
var rtApp = angular.module("realTimeNotifications", []).config(function($sceProvider) {
// Completely disable SCE to support IE7.
$sceProvider.enabled(false);
});
但还是没有运气
提前感谢。我也一直在努力解决IE7和IE6的兼容性问题,并发现使用angularjs版本1.1.5而不是1.2.25可以防止您描述的错误 除了这个简单的例子,angular在IE6和IE7中是否可用是另一回事 下面的代码已经在IE6,7,8,9,11中的兼容模式设置为on的域上进行了测试 我假设这个例子的许多部分可以省略。我刚开始使用angular,因此不能保证使用最佳实践。它至少应该提供一个起点
<!DOCTYPE html>
<html class="ng-app:phonecatApp" ng-app="phonecatApp" id="ng-app" xmlns:ng="http://angularjs.org" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE; IE=9; IE=8; IE=7" />
<meta charset="utf-8">
<title>My HTML File</title>
<link rel="stylesheet" href="../stylesheets/html5.css">
<!--[if lte IE 7]>
<script src="../Includes/Client/JS/json2.js"></script>
<![endif]-->
<!--[if lte IE 9]>
<script type="text/javascript" src="es5-shim-4.0.3-min.js"></script>
<![endif]-->
<script type="text/javascript" src="html5shiv.min.js"></script>
<script type="text/javascript" src="angular-1.1.x.js"></script>
<script type="text/javascript">
var phonecatApp = angular.module('phonecatApp', []);
phonecatApp.controller('PhoneListCtrl', function ($scope) {
$scope.phones = [
{'name': 'Nexus S',
'snippet': 'Fast just got faster with Nexus S.'},
{'name': 'Motorola XOOM™ with Wi-Fi',
'snippet': 'The Next, Next Generation tablet.'},
{'name': 'MOTOROLA XOOM™',
'snippet': 'The Next, Next Generation tablet.'}
];
});
</script>
</head>
<body ng-controller="PhoneListCtrl">
<ul>
<li ng-repeat="phone in phones">
{{phone.name}}
<p>{{phone.snippet}}</p>
</li>
</ul>
</body>
我的HTML文件
var phonecatApp=angular.module('phonecatApp',[]);
phonecatApp.controller('PhoneListCtrl',函数($scope){
$scope.phones=[
{'name':'Nexus S',
“snippet”:“使用Nexus S,Fast变得更快了”。},
{'name':'motorolaxoom™ 使用Wi-Fi’,
“snippet”:“下一代、下一代平板电脑”。},
{'name':'motorolaxoom™',
“snippet”:“下一代、下一代平板电脑。”
];
});
-
{{phone.name}
{{phone.snippet}
请参见中的“公认答案”--它提到了自举,但一般来说,正如您已经说过的,由于不支持自举,您还可以将AngularJs版本缩减到与IE7兼容的“更多”版本。-另外,请看,特别是关于支持IE 7的部分。我曾尝试过引导,但由于querySelector objectI的问题,我在评论中链接了另一篇文章,专门讨论IE,在底部有一个完整的部分,提到shivs、polly fills等等。希望这能有所帮助。您可以使用jQuery添加
document.querySelector/All(selector)
使用$(document.find(selector)
,但IE7不支持HTMLElement.prototype,因此无法将它们添加到其他元素。你为什么需要支持IE7呢?