在 Angular Probleme with IE 11 中删除字符串中的 accents/diacritics

Remove accents/diacritics in a string in Angular Probleme with IE 11

我尝试使用 String.normalize("NFD").replace(/[\u0300-\u036f]/g, "") 但我在 IE11

中有这个错误

错误类型错误:对象不支持“规范化”属性或方法

您在 IE 11 中遇到错误,因为 IE doesn't support normalize

您需要使用 polyfill 来支持 IE 11 中的 normalize。您可以使用模块 unorm 为 IE 11 中的 normalize 提供支持。

  1. 运行 npm install unorm.
  2. 在您编写 normalize 函数的文件中使用 import 'unorm';