ElemeFE / element-angular

Element for Angular
https://element-angular.faas.ele.me
MIT License
530 stars 121 forks source link

ie11不兼容 #99

Open qifanrui opened 6 years ago

qifanrui commented 6 years ago

Issue Type:

Version & Environment:
"element-angular": "^0.7.4",

Description: SCRIPT5022: Can't resolve all parameters for ElTooltip: ([object Object], [object Object], ?).

qifanrui commented 6 years ago

polyfills文件配置如下:ie11依然不能正常访问 /***

/ IE9, IE10 and IE11 requires all of the following polyfills. / import 'core-js/es6/symbol'; import 'core-js/es6/object'; import 'core-js/es6/function'; import 'core-js/es6/parse-int'; import 'core-js/es6/parse-float'; import 'core-js/es6/number'; import 'core-js/es6/math'; import 'core-js/es6/string'; import 'core-js/es6/date'; import 'core-js/es6/array'; import 'core-js/es6/regexp'; import 'core-js/es6/map'; import 'core-js/es6/weak-map'; import 'core-js/es6/set';

/* IE10 and IE11 requires the following for NgClass support on SVG elements / import 'classlist.js'; // Run npm install --save classlist.js.

/* IE10 and IE11 requires the following for the Reflect API. / import 'core-js/es6/reflect';

/ Evergreen browsers require these. / // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. import 'core-js/es7/reflect';

/**

/**

(window as any).Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame (window as any).Zone_disable_on_property = true; // disable patch onProperty such as onclick (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames

/*

/***

/***

import "babel-polyfill"

unix commented 6 years ago

应该是 IE 下有部分的语法不支持 (但我不确定是哪一部分),目前 element-angular 导出的包是 ES5,理论上是没有问题的,你能提供更多的错误信息吗。

seimyle commented 5 years ago

我在IE11调试的时候的发现所有调用WindowWrapper和DocumentWrapper的地方都会报这个错 Can't resolve all parameters for ElTooltip, 出错的地方在:

CompileMetadataResolver.prototype._getDependenciesMetadata = function (typeOrFunc, dependencies, throwOnUnknownDeps) { var _this = this; if (throwOnUnknownDeps === void 0) { throwOnUnknownDeps = true; } var hasUnknownDeps = false; var params = dependencies || this._reflector.parameters(typeOrFunc) || []; var dependenciesMetadata = params.map(function (param) { var isAttribute = false; var isHost = false; var isSelf = false; var isSkipSelf = false; var isOptional = false; var token = null; if (Array.isArray(param)) { param.forEach(function (paramEntry) { if (createHost.isTypeOf(paramEntry)) { isHost = true; } else if (createSelf.isTypeOf(paramEntry)) { isSelf = true; } else if (createSkipSelf.isTypeOf(paramEntry)) { isSkipSelf = true; } else if (createOptional.isTypeOf(paramEntry)) { isOptional = true; } else if (createAttribute.isTypeOf(paramEntry)) { isAttribute = true; token = paramEntry.attributeName; } else if (createInject.isTypeOf(paramEntry)) { token = paramEntry.token; } else if (createInjectionToken.isTypeOf(paramEntry) || paramEntry instanceof StaticSymbol) { token = paramEntry; } else if (isValidType(paramEntry) && token == null) { token = paramEntry; } }); } else { token = param; } if (token == null) { hasUnknownDeps = true; return null; } return { isAttribute: isAttribute, isHost: isHost, isSelf: isSelf, isSkipSelf: isSkipSelf, isOptional: isOptional, token: _this._getTokenMetadata(token) }; }); if (hasUnknownDeps) { var depsTokens = dependenciesMetadata.map(function (dep) { return dep ? stringifyType(dep.token) : '?'; }).join(', '); var message = "Can't resolve all parameters for " + stringifyType(typeOrFunc) + ": (" + depsTokens + ")."; if (throwOnUnknownDeps || this._config.strictInjectionParameters) { this._reportError(syntaxError(message), typeOrFunc); } else { this._console.warn("Warning: " + message + " This will become an error in Angular v6.x"); } } return dependenciesMetadata; };

参数window和document在IE11不满足这些条件,我尝试通过修改源码的方式让他匹配也不行

后来我在网上找到一个知识点: 如果所创建的服务不依赖于其他对象,是可以不用使用 Injectable 类装饰器。但当该服务需要在构造函数中注入依赖对象,就需要使用 Injectable 装饰器。不过比较推荐的做法不管是否有依赖对象,在创建服务时都使用 Injectable 类装饰器。 所以我想加@Injectable()试一下,但是node里面的是已经编译过的版本,不知道怎么加,然后你们能不能试一下

seimyle commented 5 years ago

image 我注释了这两行代码就可以显示出来,但是我感觉会有其他问题产生