【发布时间】:2017-10-11 11:51:33
【问题描述】:
我的代码在这里:https://jsfiddle.net/woyuditan26/bgwrfLxh/
this.setState((prevState) => ({
tasks: prevState.tasks.concat(newTask),
text: '' //// why the input text is not cleared when I clicked the button ?
}));
为什么我点击按钮时输入的文字没有被清除?
【问题讨论】:
-
你在哪里使用
text? -
我们是否有“debug-my-code”标签或类似标签?
-
我建议你阅读这个react/docs/forms。
-
因为您的表单是“不受控制的”:)