【发布时间】:2017-11-09 13:31:25
【问题描述】:
我需要开发一个HTML application (HTA) 来解决业务问题。我认为在后台使用Angular 会大大简化开发。
我通过ng new 创建了一个新的 Angular 项目并进行了一些小改动(详情如下),但是当我运行构建的 HTA 文件时,我得到了这个错误:
错误:“控制台”未定义
并且页面永远不会在 HTA 窗口中加载。
HTA 使用 IE 9(应用的要求禁止使用更高版本的浏览器),因此应用包含此元标记:
<meta http-equiv="X-UA-Compatible" content="IE=9">
Angular's documentation states that IE 9 is supported 如果我取消注释 polyfills.ts 中所有必要的 polyfill,我已经完成了:
/** 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';
我已将包含的index.html 文件重命名为index.hta 并在.angular-cli.json 中进行了相应的更改。
我尝试将以下代码直接放入polyfills.ts 以规避缺少的console:
if (!window.console) console = {error: function() {}};
但是我根本无法构建,因为它不喜欢我重新定义console:
ERROR in src/polyfills.ts(77,22): error TS2322: Type '{ error: () => void; }' is not assignable to type 'Console'.
Property 'assert' is missing in type '{ error: () => void; }'.
任何人都可以从这里提出一条前进的道路吗?
【问题讨论】:
标签: javascript angular internet-explorer-9 ecmascript-5 hta