antd3自定义表单项怎样触发规则校验?-灵析社区

ciiiiinema

在antd3的自定义表单项中,为什么无法触发规则校验 只有这样写才可以 class CheckInput extends PureComponent { handleNumberChange = (e) => { const { onChange } = this.props; if (onChange) { onChange(e.target.value); } } render() { const { value } = this.props; return ( ); } } ![image.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20240927/071fa020757ab57a8f17900e6185108c.png) 像下面这样写就不能触发错误校验 class CheckInput extends PureComponent { constructor(props) { super(props); this.state = { value: props.value }; } handleNumberChange = (e) => { console.log(e.target.value); this.setState({ value: e.target.value }); } render() { const { value } = this.state; return ( ); } } ![image.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20240927/8e943754c9af3cd7e5c6298a401bc3a9.png) 不是特别理解第一种方式,有大佬可以讲解一下嘛

阅读量:172

点赞量:0

问AI
销售经理537
你想使用 antd 校验规则 首先要把 被包裹的组件的状态控制权交给 antd "props:{ value , onChange } "