我有一个数据表,显示来自外部API的数据,我希望表页上的项目/元素数量应保存在本地存储中
以下是我迄今为止try 过的:
ngOnInit() {
this.moviesService.getPopularTVShows().subscribe(res => {
this.dataSource = new MatTableDataSource(res.results);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
localStorage.setItem(this.dataSource, this.dataSource.length);
console.log(localStorage.length);
});
}
当我运行应用程序时,控制台显示undefined
我的代码怎么了?欢迎任何帮助或建议,新手try 新东西.