React 无法识别 img 元素上 DOM 元素上的 `isDisabled` 属性

问题描述 投票:0回答:1

更新我的 React/Next.js 应用程序后,我收到此错误:

React 无法识别 DOM 元素上的

isDisabled
属性。如果您有意希望它作为自定义属性出现在 DOM 中,请将其拼写为小写
isdisabled
。如果您不小心从父组件传递了它,请将其从 DOM 元素中删除。

这就是我使用该img的方式:

<img src={user?.photoURL ? user?.photoURL : "https://xxxxxxx"} alt="avatar" className="w-8 h-8 rounded-full border-2 border-violet-600 cursor-pointer" />

如果我删除

<img>
并将其替换为 a,那么
<span>
错误就消失了。

javascript reactjs next.js
1个回答
0
投票

React 不支持 isDisabled 属性,请尝试使用 disabled 属性,如下所示:

<img disabled={true} src={user?.photoURL ? user?.photoURL : "https://xxxxxxx"} alt="avatar" className="w-8 h-8 rounded-full border-2 border-violet-600 cursor-pointer" />
© www.soinside.com 2019 - 2024. All rights reserved.