我是 SharePoint SPFX 开发新手。由于我是 SharePoint SPFx 的新手,我正在尝试以下 Microsoft 官方教程 将客户端 Web 部件连接到 SharePoint(Hello World 第 2 部分)。
我成功完成了本教程系列的第 01 部分,构建您的第一个 SharePoint 客户端 Web 部件(Hello World 第 1 部分)
当我遵循第 02 部分时,我陷入了以下 2 种方法
01
private _renderListAsync(): void {
this._getListData()
.then((response) => {
this._renderList(response.value);
})
.catch(() => {});
}
错误出现在第 4 行(response.value),即“Argument of type 'ISPLists[]' is not assignable to argument of type 'ISPList[]'”。 类型“ISPLists”缺少类型“ISPList”中的以下属性:标题、Idts(2345)'
同样在第 6 行方法中 (.catch(() => {});),即“意外的空箭头函数.eslint@typescript-eslint/no-empty-function”
02
private _getListData(): Promise<ISPLists> {
return this.context.spHttpClient.get(`${this.context.pageContext.web.absoluteUrl}/_api/web/lists?$filter=Hidden eq false`, SPHttpClient.configurations.v1)
.then((response: SPHttpClientResponse) => {
return response.json();
})
.catch(() => {});
}
错误位于第 6 行 (.catch(() => {});),即意外的空箭头函数。eslint@typescript-eslint/no-empty-function
我尝试了很多线程,但没有得到答案。
我正在使用 SharePoint Online、NodeJs 16.20.0、NPM 8.19.4,而不使用任何前端框架(如 React 或 Angular)。
解决方案的源代码请参考以下链接。 源代码 你能帮我解决这个问题吗?
最诚挚的问候, 奇兰塔卡J
我找到了问题的答案。
对于“
.catch(() => {});
”中的问题,请使用“.catch((err) => { console.log(err); });
”
对于“ISPList[]”问题。类型“ISPLists”缺少类型“ISPList”中的以下属性:标题,Idts(2345)”按照说明完成源代码,直到教程第 2 页结束,问题将自动消失。