We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
当存在如下结构时:
onDateTimeChange(c, value) { let model = this.state.model; model.date = value; this.setState({ model: model }) } render() { return ( <Row className="pcdn-panel" style={{marginTop: 0}}> <FormItem label="加速域名" model="model.domain" rules={{required: true}} messages={{required: '请至少选择一个域名'}} > <Select value={this.state.model.domain} style={{width: "400px"}} placeholder="支持多选" on$change-value={$.proxy(this.onDomainChange, this)} multiple clearable filterable> <Option value="Monday">星期一</Option> </Select> </FormItem> <hr /> </Row> ) }
多选的Select值无法被清空,原因是FormItem下存在并列的hr元素,当清空值时,首先调用onDomainChange函数改变state,然后改变的值传给FormItem,FormItem检测到数据变更,又会再次调用setState改变model属性绑定的属性,这回导致更新队列不会立即执行。
Select
FormItem
hr
onDomainChange
state
setState
model
Select内部使用了Animate组件,该组件会在更新之前(_beforeUpdate)计算children,更新之后(_update)根据children执行动画,清空后children会置为删除的子元素,但第二次更新时,children则会为空,因为已经没有需要删除的子元素了。如果_beforeUpdate和_update先后执行,则没有问题,但如果执行了两次_beforeUpdate则会导致children丢失了
Animate
_beforeUpdate
children
_update
FormItem绑定的model属性会去setState导致在_beforeUpdate和_update之间又插入了一次_beforeUpdate,所以元素不能被正确清空
The text was updated successfully, but these errors were encountered:
Javey/Intact@6360640
fix: should not update the instance which will leave, ksc-fe/kpc#238
edb3703
No branches or pull requests
当存在如下结构时:
多选的
Select
值无法被清空,原因是FormItem
下存在并列的hr
元素,当清空值时,首先调用onDomainChange
函数改变state
,然后改变的值传给FormItem
,FormItem
检测到数据变更,又会再次调用setState
改变model
属性绑定的属性,这回导致更新队列不会立即执行。Select
内部使用了Animate
组件,该组件会在更新之前(_beforeUpdate
)计算children
,更新之后(_update
)根据children
执行动画,清空后children
会置为删除的子元素,但第二次更新时,children
则会为空,因为已经没有需要删除的子元素了。如果_beforeUpdate
和_update
先后执行,则没有问题,但如果执行了两次_beforeUpdate
则会导致children
丢失了FormItem
绑定的model
属性会去setState
导致在_beforeUpdate
和_update
之间又插入了一次_beforeUpdate
,所以元素不能被正确清空The text was updated successfully, but these errors were encountered: