繁体   English   中英

如何在运行IE 9的HTA中使Angular工作?

[英]How do I get Angular working in an HTA running IE 9?

我需要开发一个HTML应用程序 (HTA)来解决业务问题。 我认为在后台使用Angular将大大简化开发。

我已经通过ng new创建了一个新的Angular项目,并做了一些小的更改(在下面进行了详细介绍),但是当我运行内置的HTA文件时,出现此错误:

错误:“控制台”未定义

并且页面永远不会加载到HTA窗口中。

HTA使用IE 9(该应用程序的要求禁止使用更高版本的浏览器),因此该应用程序包含以下元标记:

<meta http-equiv="X-UA-Compatible" content="IE=9">

角的文档指出IE 9支持 ,如果我去掉所有必要的polyfills的polyfills.ts ,我已经做了:

/** 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; }'.

有人可以建议从这里前进的方法吗?

我通过在index.hta<app-root></app-root>行下添加以下代码来解决此问题:

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

现在,当我双击HTA文件时,出现“欢迎使用应用程序!”屏幕。

看来Angular的构建过程看起来并不像在主页内声明的JavaScript那样紧密。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM