英文:
Module '"primeng/utils"' has no exported member 'FilterUtils'
问题
升级 Angular 到 v15 后,我遇到了这个错误:
> 模块 "'primeng/utils'" 没有导出成员 "'FilterUtils'"。
是否有不需要更改代码的替代方法来进行筛选?
import { FilterUtils } from ''primeng/utils'';
filterStatus(event: Switch, dt: Table): void {
this.showErrorOnly = event.checked;
if (event.checked) {
dt.value = FilterUtils.filter(this.data, ['validation.status'], 'INVALID', 'contains');
} else {
dt.value = this.data;
}
dt.reset()
}
英文:
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?
import { FilterUtils } from 'primeng/utils';
filterStatus(event: Switch, dt: Table): void {
this.showErrorOnly = event.checked;
if (event.checked) {
dt.value = FilterUtils.filter(this.data, ['validation.status'], 'INVALID', 'contains');
} else {
dt.value = this.data;
}
dt.reset()
}
答案1
得分: 1
FilterUtils
在 PrimeNG 11 中被移除,FilterService
类被提供作为替代品:
import { FilterService } from 'primeng/api';
@Component({
...
providers: [FilterService] // 你也可以在 AppModule 中全局提供它
})
class SomeComponent {
constructor (private readonly filterService: FilterService) {}
filterStatus(event: Switch, dt: Table): void {
this.showErrorOnly = event.checked;
if (event.checked) {
dt.value = this.filterService.filter(this.data, ['validation.status'], 'INVALID', 'contains');
} else {
dt.value = this.data;
}
dt.reset();
}
}
英文:
FilterUtils
were removed in PrimeNG 11 and the FilterService
class was provided as the replacement:
import { FilterService } from 'primeng/api';
@Component({
...
providers: [FilterService] // you can also provide it globally in the AppModule
})
class SomeComponent {
constructor (private readonly filterService: FilterService) {}
filterStatus(event: Switch, dt: Table): void {
this.showErrorOnly = event.checked;
if (event.checked) {
dt.value = this.filterService.filter(this.data, ['validation.status'], 'INVALID', 'contains');
} else {
dt.value = this.data;
}
dt.reset();
}
}
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论