【发布时间】:2021-08-19 19:10:42
【问题描述】:
我在一个数组中有一个map,并且对于每个项目,我都会渲染一个具有 disabled 属性的组件,其中包含要检查的内容,但是在 input 标记中这不起作用,对于所有渲染的组件,只考虑第一个结果。例如:first_result = false 然后all_results = false。
const array = [1, 2, 3, 4, 5];
{array.map((item, index) => (
<div>
<input
id="icon-button-file"
accept="image/*"
type="file"
multiple="multiple"
onChange={(e) => setState(e.target.files)}
style={{ display: "none" }}
disabled={index % 2 === 0}
/>
<label htmlFor="icon-button-file">
<IconButton
color="primary"
aria-label="upload picture"
component="span"
disabled={index % 2 === 0}
>
<PhotoCamera />
</IconButton>
</label>
</div>
))}
【问题讨论】:
-
请阅读Something on my web site doesn't work. Can I just paste a link to it?。当外部资源消失或固定时,依赖于外部资源来理解的问题变得毫无用处。创建一个minimal reproducible example 并将其放入问题本身。 Stackoverflow 确实支持inline live demos
标签: html reactjs material-ui