我有一个使用vis.js的AngularJs网络应用程序,它与IE9+兼容,但我试图使这个web应用程序与IE8兼容,同时减少用户可以使用的功能,,因为我必须使用。
我包括了以下库来处理常见的IE8兼容性问题:
<!--[if lte IE 9]>
<script type='text/javascript' src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.7.1/modernizr.min.js"></script>
<script type='text/javascript' src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<script type='text/javascript' src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
<script type='text/javascript' src="scripts/eventShim.js"></script>
<script>
// here I create the elements for all the custom directives
document.createElement('custom-handler');
document.createElement('custom-info');
document.createElement('custom-data');
document.createElement('custom-param');
document.createElement('custom-rel');
document.createElement('custom-panel');
// Optionally these for CSS
document.createElement('ng:include');
document.createElement('ng:pluralize');
document.createElement('ng:view');
document.createElement('ng:style');
document.createElement('ng:class');
</script>
<![endif]-->然后用凉亭:
<!-- build:js(.) scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/json3/lib/json3.js"></script>
...
<!-- endbower -->
<!-- endbuild -->在bower.json中定义的库的显著版本
"angular": "1.2",
"jquery": "1.11.2",
"json3": "~3.3.2",
"es5-shim": "~4.1.11",
"bootstrap-sass-official": "~3.3.5",
"angular-animate": "~1.2.0",
"angular-cookies": "~1.2.0",
"angular-resource": "~1.2.0",
"angular-route": "~1.2.0",
"angular-sanitize": "~1.2.0",
"angular-touch": "~1.2.0",
"angular-bootstrap": "0.12.0",
"vis": "~3.7.2",
"string": "~3.0.0",
"components-font-awesome": "~4.4.0",
"jquery-ui": "~1.11.4"问题
尽管有上述所有设置,但当我使用IE8访问我的web应用程序时,在控制台中会出现以下错误:
Object doesn't support this property or method vis.min.js, line 29 character 1204通过单击它,控制台将光标放置在以下代码行的开头:
s.prototype=Object.create(o.prototype),s.prototype.redraw=function(...即使我注释了使用vis.js的HTML,错误仍然存在。
当vis.js应用程序在IE9+中打开时,我无法在保龄球中找到一种方法来包含IE9+库,所以我的B计划就是消除与vis.js相关的错误,然后在web应用程序中使用这个库的所有功能都是不可否认的。
这种方法能起作用吗?
如果不是,我如何解决这个问题?
发布于 2015-08-28 09:44:18
当web应用程序在vis.js中被打开时,我无法在bower中找到包含IE9+库的方法。
Bower只能包括消息来源。
对于这样的任务,创建了一个gulp。
例如,您的建筑将以这样的代码存在:
var gulp = require('gulp')
var bowerFiles = require('main-bower-files');
var gulpFilter = require('gulp-filter');
var gulpInject = require('gulp-inject');
gulp.task('wiredep', function() {
var ie8Files = ['**/json3.js', '**/es5shim.js'];
// the same as: var restFiles = ['*', '!**/json3.js', '!**/es5shim.js'];
var restFiles = ['*'].concat(ie8Files.map(function(e) { return '!' + e;}));
gulp.src('index.html')
.pipe(gulpInject(gulp.src(bowerFiles(), {read: false}).pipe(restFiles))
.pipe(gulpInject(gulp.src(bowerFiles(), {read: false}).pipe(ie8Files),
{starttag: '<!--[if lt IE 9]>', endtag: '<![endif]-->'})
.pipe(gulp.dest('dist'));
});或者就像你说的B计划:
您可以为您的代码编写所有循环,如:
if (!Object.create) {
Object.create = function(o, properties) {
if (typeof o !== 'object' && typeof o !== 'function') throw new TypeError('Object prototype may only be an Object: ' + o);
else if (o === null) throw new Error("This browser's implementation of Object.create is a shim and doesn't support 'null' as the first argument.");
if (typeof properties != 'undefined') throw new Error("This browser's implementation of Object.create is a shim and doesn't support a second argument.");
function F() {}
F.prototype = o;
return new F();
};
}在我看来,你应该加上一个吞咽结构。
https://stackoverflow.com/questions/32267597
复制相似问题