【问题标题】:How do I get Angular working in an HTA running IE 9?如何让 Angular 在运行 IE 9 的 HTA 中工作?
【发布时间】: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


    【解决方案1】:

    我通过在index.hta&lt;app-root&gt;&lt;/app-root&gt; 行下添加以下代码解决了这个问题:

    <script>
      // HTAs don't have a console.
      console = {};
    </script>
    

    我现在收到“欢迎使用应用程序!”双击 HTA 文件时的屏幕。

    Angular 的构建过程似乎不像在主页中声明的 JavaScript 那样仔细。

    【讨论】:

      猜你喜欢
      • 2012-06-09
      • 1970-01-01
      • 1970-01-01
      • 2013-02-16
      • 1970-01-01
      • 1970-01-01
      • 2013-10-06
      • 2012-11-12
      • 1970-01-01
      相关资源
      最近更新 更多