const handerField = (item: number) => {
caselist= data.showList[item]//报错
}
解决方法:
const handerField = (item: number) => {
caselist= (data.showList as any)[item];
}
const handerField = (item: number) => {
caselist= data.showList [item as keyof typeof data.showList ]
}
const handerField = function <T extends object, K extends keyof T>(obj: T, key: K) {
return obj[key];
}