let inProcessCount: number | undefined; async function getInProcessCount() { if (inProcessCount !== undefined) { return inProcessCount; } const list = await store.dispatch('ESourcingModule/GetMyRequest', searchView.value); // eslint-disable-next-line @typescript-eslint/no-unsafe-call const len = list.filter((o: { ViewType: string }) => o.ViewType === 'InClarification' || o.ViewType === 'SupplementEventDetails').length; inProcessCount = len; if (eSourcingRoute) { // 如果 eSourcingRoute 变量不为 undefined const myRequestIndex = eSourcingRoute.findIndex(route => route.meta?.title === 'My Request'); if (myRequestIndex !== -1 && eSourcingRoute[myRequestIndex].meta !== undefined) { eSourcingRoute[myRequestIndex].meta.title = 'My Request (2)' } r } eturn inProcessCount as number; }
时间: 2024-01-25 17:04:43 浏览: 116
ea-async:EA Async在JVM中实现async-await方法
代码中的问题在于 `r` 这个字符,它是一个语法错误,应该删除掉。
另外,代码中对 `eSourcingRoute` 变量的访问也存在问题,应该修改为 `if (eSourcingRoute !== undefined)`,这样才能避免 TypeScript 的类型检查错误。具体修改后的代码如下:
```
let inProcessCount: number | undefined;
async function getInProcessCount() {
if (inProcessCount !== undefined) {
return inProcessCount;
}
const list = await store.dispatch('ESourcingModule/GetMyRequest', searchView.value);
const len = list.filter((o: { ViewType: string }) => o.ViewType === 'InClarification' || o.ViewType === 'SupplementEventDetails').length;
inProcessCount = len;
if (eSourcingRoute !== undefined) {
const myRequestIndex = eSourcingRoute.findIndex(route => route.meta?.title === 'My Request');
if (myRequestIndex !== -1 && eSourcingRoute[myRequestIndex].meta !== undefined) {
eSourcingRoute[myRequestIndex].meta.title = 'My Request (2)';
}
}
return inProcessCount as number;
}
```
修改后,代码中的问题应该就解决了。
阅读全文