Angular 6.x 在 IE 11 中不起作用 - 错误:参数无效 [英] Angular 6.x not working in IE 11 - Error: Invalid argument

查看:18
本文介绍了Angular 6.x 在 IE 11 中不起作用 - 错误:参数无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Chrome 中完美运行的 Angular 6.x 应用程序.问题是尝试在 IE 11 中运行它时,出现错误:

I have an Angular 6.x app running perfectly in Chrome. The problem is when trying to run it in IE 11, I'm getting the error:

错误:无效的参数.在 DefaultDomRenderer2.prototype.setProperty...

Error: Invalid argument. at DefaultDomRenderer2.prototype.setProperty...

已经在 StackOverflow 中尝试了所有我在没有帮助的情况下找到的答案.我在这里列出主题,所以你们不会尝试将它们作为答案:

Already tried all answers in StackOverflow that I could find with no help. I'm listing theme here so you guys won't try them as answers:

  • 添加了 IE 所需的所有 polyfill,但仍然存在相同的问题.
  • 添加到 head 标签中:

  • Added all polyfills needed for IE but still having the same problem.
  • Added in head tag:

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

感谢您的帮助.

推荐答案

我已经发现问题并修复了它.我写这个答案是为了为面临这个问题的其他人节省时间.

I've found the problem and fixed it. I'm writing this answer to save time for others facing this problem.

问题是将不正确值的变量绑定到HTML 属性(任何 HTML 属性).

The problem is binding an incorrect valued variable to an HTML attribute (any HTML attribute).

例如

dir 属性分配变量p 标记,必须定义为 dir 属性的可能值之一,它们是:ltr |rtl |自动

Assigning a variable to a dir attribute in a p tag, must be defined with one of the possible values for dir attribute, which are: ltr | rtl | auto

在 html 中有这一行:<p [dir]="myDir">Test</p>

Having this line in html: <p [dir]="myDir">Test</p>

myDir = undefinedmyDir = 'bla bla bla' 或任何其他不正确的值 - 我们将收到错误.

When myDir = undefined or myDir = 'bla bla bla' or any other incorrect value - we'll get an error.

myDir = 'rtl' 或任何其他正确值时 - 我们不会得到错误.

When myDir = 'rtl' or any other correct value - we won't get an error.

添加了一个 DEMO 以在 IE 中运行以查看重现此错误.

Added a DEMO to run in IE for seeing this error reproduced.

结论我想我们可以说,当绑定到一个 HTML 属性时,我们必须非常小心地拥有一个有效的属性值,这样我们就不会遇到这个问题.

For conclusion I think we can say that when binding to an HTML attribute we'll have to be very careful to have a valid attribute's value, this way we won't face this problem.

这篇关于Angular 6.x 在 IE 11 中不起作用 - 错误:参数无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆