Module “primeng/utils”没有导出成员”FilterUtils”。

huangapple go评论100阅读模式
英文:

Module '"primeng/utils"' has no exported member 'FilterUtils'

问题

升级 Angular 到 v15 后,我遇到了这个错误:

> 模块 "'primeng/utils'" 没有导出成员 "'FilterUtils'"。

是否有不需要更改代码的替代方法来进行筛选?

  1. import { FilterUtils } from ''primeng/utils'';
  2. filterStatus(event: Switch, dt: Table): void {
  3. this.showErrorOnly = event.checked;
  4. if (event.checked) {
  5. dt.value = FilterUtils.filter(this.data, ['validation.status'], 'INVALID', 'contains');
  6. } else {
  7. dt.value = this.data;
  8. }
  9. dt.reset()
  10. }
英文:

After upgrading Angular to v15 I am getting this error:

> Module '"primeng/utils"' has no exported member 'FilterUtils'.

Is there any alternative of filtering like this without code changes?

  1. import { FilterUtils } from 'primeng/utils';
  2. filterStatus(event: Switch, dt: Table): void {
  3. this.showErrorOnly = event.checked;
  4. if (event.checked) {
  5. dt.value = FilterUtils.filter(this.data, ['validation.status'], 'INVALID', 'contains');
  6. } else {
  7. dt.value = this.data;
  8. }
  9. dt.reset()
  10. }

答案1

得分: 1

FilterUtils 在 PrimeNG 11 中被移除,FilterService 类被提供作为替代品:

  1. import { FilterService } from 'primeng/api';
  2. @Component({
  3. ...
  4. providers: [FilterService] // 你也可以在 AppModule 中全局提供它
  5. })
  6. class SomeComponent {
  7. constructor (private readonly filterService: FilterService) {}
  8. filterStatus(event: Switch, dt: Table): void {
  9. this.showErrorOnly = event.checked;
  10. if (event.checked) {
  11. dt.value = this.filterService.filter(this.data, ['validation.status'], 'INVALID', 'contains');
  12. } else {
  13. dt.value = this.data;
  14. }
  15. dt.reset();
  16. }
  17. }
英文:

FilterUtils were removed in PrimeNG 11 and the FilterService class was provided as the replacement:

  1. import { FilterService } from 'primeng/api';
  2. @Component({
  3. ...
  4. providers: [FilterService] // you can also provide it globally in the AppModule
  5. })
  6. class SomeComponent {
  7. constructor (private readonly filterService: FilterService) {}
  8. filterStatus(event: Switch, dt: Table): void {
  9. this.showErrorOnly = event.checked;
  10. if (event.checked) {
  11. dt.value = this.filterService.filter(this.data, ['validation.status'], 'INVALID', 'contains');
  12. } else {
  13. dt.value = this.data;
  14. }
  15. dt.reset();
  16. }
  17. }

答案2

得分: 0

使用import { FilterUtils } from 'Primeng/utils';PrimeNg版本11中已被弃用。如果您想要不进行代码更改的解决方案,我建议您将PrimeNg版本降级到v10.0.0(lts)。请查看官方PrimeNg v10文档此处

英文:

Use of import { FilterUtils } from 'Primeng/utils'; is deprecated in PrimeNg version 11. If you are looking for something without a code change. I suggest you to downgrade the version of primeNg to v10.0.0(lts) Please find the official PrimeNg v10 documentation here.

huangapple
  • 本文由 发表于 2023年6月12日 18:10:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76455603.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定