antd "clear" values ​​within cascade - Stack Overflow
天蓬老师
天蓬老师 2017-05-19 10:36:29
0
4
821

Scenario description
1. Wrap the cascade component twice
2. Use it in the news list editing function. The editing function is to pop up a form box that mimics the box

Problem description
Every time you click on any of the pop-up pseudo-box forms for editing, select any value in the cascade component inside, then click to close the editing pseudo-box, and then click on any piece of news When editing, the pop-up simulation box will display the undetermined submitted value of the last selection by default.

Tried methods
Used the form reset methodresetFields The value in the cascading box cannot be cleared. I found some posts in antd's github and the attempts are still invalid. I learned from one of the posts that https://github.com/ant-design... resetFields is reset and cannot be cleared.

Ideal goal
Every time I click edit, I want to force clear the value inside.

Thank you everyone~!

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(4)
过去多啦不再A梦

Clear the cascaded value in the componentDidMount life cycle

迷茫

Bind the value of the component to the state and set an initial value.

Ty80

I don’t know if the questioner used antd FormForm.item?如果是的话,antd 是使用了“高阶函数”的方式封装了 Form.Item,并将级联的 valueForm.IteminitialValuevalue(好吧,我也记不清了...) 关联了,二次封装的话,应该使用相应的 this.props.value 来控制封装逐渐内部的 value.

大家讲道理

I haven’t seen your code, so I don’t know how you implemented it, but the simplest way is to bind the value and state of your component. When you want to clear the value of the component, just reset the setState.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template