P.S.我已经尝试了其他的答案,从计算器,但不知何故,没有工作。
我的结合 this
至击功能处理程序,如下面给出
const handleUpdatePermissionClick = async (user: UserPermission) => {
try {
await updateUserPermission(user)
setShowError(false)
} catch (e) {
setShowError(true)
}
}
<MenuItem
name={ele.name}
Key={ele.name}
onClick={handleUpdatePermissionClick.bind(this, { permission: ele, userId })}
/>
但它给我 Parameter 'this' implicitly has an 'any' type
错误`。
我试着分配多个类型,即。 任何无效的,类型来 this
作为
onClick={handleUpdatePermissionClick.bind(this:any, { permission: ele, userId })}
但它给人类不必要的错误。 请帮助我这一问题。