【发布时间】:2018-07-20 10:34:49
【问题描述】:
我正在尝试在组件状态更改时更改输入的名称属性。
简而言之,这就是我想要做的。
let displayInputElement = (
<input
type="text"
name = {pips}
placeholder="Type your answer here"
className=" form-control"
/>
);
displayInputElement.props.name = "chicken";
但我收到以下错误
TypeError:无法分配给对象“#”的只读属性“名称”
请问我如何在反应中实现以下目标
displayInputElement.props.name = "chicken";
let pips = displayInputElement.props.name;
displayInputElement = (
<input
type="text"
name = "chicken"
placeholder="Type your answer here"
className=" form-control"
/>
);
【问题讨论】:
标签: javascript reactjs