diff --git a/packages/discuz-design/components/input/interface.ts b/packages/discuz-design/components/input/interface.ts index 67ff3f789394a0c74d3080d2df07e48a15759bb8..e8f91ce14d8a8af99adcaaabc93e94dc76c5d9c8 100644 --- a/packages/discuz-design/components/input/interface.ts +++ b/packages/discuz-design/components/input/interface.ts @@ -13,7 +13,8 @@ interface BaseInputProps extends StyledProps { mode?: 'password' | 'search' | 'number'; /** - * 输入框当前值,开发者需要通过 onChange 事件来更新 value 值,必填 + * 输入框当前值,开发者需要通过 onChange 事件来更新 value 值,必填 (弃用) + * 输入框初始值(类似于 defalutValue),开发者需要使用 e.target.value 取用输入框出的当前值,选填 ( 新 ) * @default "" * @requires true */ diff --git a/packages/discuz-design/components/input/layouts/mini.tsx b/packages/discuz-design/components/input/layouts/mini.tsx index 9f343ad6f33acd4abf8d3654aa6df51ef56b9ac6..2ed4984b728fb961afba892983d566376bae0b35 100644 --- a/packages/discuz-design/components/input/layouts/mini.tsx +++ b/packages/discuz-design/components/input/layouts/mini.tsx @@ -20,6 +20,22 @@ export class MiniLayout extends Component { isPassword: props.mode === 'password', isFocus: false, }; + + this.inputRef = React.createRef(); // 因ios小程序输入框闪烁,故此 + } + + componentDidMount() {// 因ios小程序输入框闪烁,故此 + this.inputRef.current.value = this.props.value || ''; + } + + componentDidUpdate(pre){ + if(pre.value !== '' && this.props.value === ''){ + this.inputRef.current.value = ''; + } + } + + componentWillUnmount(){ + this.inputRef.current.value = ''; } onIconClick(event): void { @@ -180,11 +196,11 @@ export class MiniLayout extends Component { {modeNode} {prefixIconNode}