在 angular 7 中使用 primeng table 时出错
Error while using primeng table with angular 7
我正在尝试将 primeng-table 与 angular7 一起使用。但是在集成它之后我收到以下错误:-
Uncaught TypeError: Object(...) is not a function
at platform.es5.js:102
at Module../node_modules/@angular/cdk/esm5/platform.es5.js (platform.es5.js:104)
at webpack_require (bootstrap:78)
at Module../node_modules/@angular/cdk/esm5/scrolling.es5.js (scrolling.es5.js:1)
at webpack_require (bootstrap:78)
at Object../node_modules/primeng/components/dropdown/dropdown.js (dropdown.js:12)
at webpack_require (bootstrap:78)
at Object../node_modules/primeng/components/paginator/paginator.js (paginator.js:15)
at webpack_require (bootstrap:78)
at Object../node_modules/primeng/components/datagrid/datagrid.js (datagrid.js:15)
html 文件
<html>
<div class="courses">
<h1>This is the Courses Page!</h1>
<br><br><br><br>
</div>
<p-dataTable [value]="courses">
<p-column field="id" header="id"></p-column>
<p-column field="name" header="name"></p-column>
</p-dataTable>
</html>
组件文件
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-courses',
templateUrl: './courses.component.html',
styleUrls: ['./courses.component.less']
})
export class CoursesComponent implements OnInit {
courses: any[];
constructor() { }
ngOnInit() {
this.courses = [
{ id: '1', name: 'Course1' },
{ id: '2', name: 'Course2' },
{ id: '3', name: 'Course3' }
];
}
}
您可以在此处找到完整代码 - Code
谁能告诉我哪里做错了?
谢谢!
您好,请更新依赖项并使用 TableModule 中的 p-table,它工作正常,请检查包 json。这里是 stackblitz
希望对您有所帮助!
我正在尝试将 primeng-table 与 angular7 一起使用。但是在集成它之后我收到以下错误:-
Uncaught TypeError: Object(...) is not a function at platform.es5.js:102 at Module../node_modules/@angular/cdk/esm5/platform.es5.js (platform.es5.js:104) at webpack_require (bootstrap:78) at Module../node_modules/@angular/cdk/esm5/scrolling.es5.js (scrolling.es5.js:1) at webpack_require (bootstrap:78) at Object../node_modules/primeng/components/dropdown/dropdown.js (dropdown.js:12) at webpack_require (bootstrap:78) at Object../node_modules/primeng/components/paginator/paginator.js (paginator.js:15) at webpack_require (bootstrap:78) at Object../node_modules/primeng/components/datagrid/datagrid.js (datagrid.js:15)
html 文件
<html>
<div class="courses">
<h1>This is the Courses Page!</h1>
<br><br><br><br>
</div>
<p-dataTable [value]="courses">
<p-column field="id" header="id"></p-column>
<p-column field="name" header="name"></p-column>
</p-dataTable>
</html>
组件文件
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-courses',
templateUrl: './courses.component.html',
styleUrls: ['./courses.component.less']
})
export class CoursesComponent implements OnInit {
courses: any[];
constructor() { }
ngOnInit() {
this.courses = [
{ id: '1', name: 'Course1' },
{ id: '2', name: 'Course2' },
{ id: '3', name: 'Course3' }
];
}
}
您可以在此处找到完整代码 - Code
谁能告诉我哪里做错了?
谢谢!
您好,请更新依赖项并使用 TableModule 中的 p-table,它工作正常,请检查包 json。这里是 stackblitz 希望对您有所帮助!