diff --git a/components/Input/Input.jsx b/components/Input/Input.jsx index 60c996eda..6547da892 100644 --- a/components/Input/Input.jsx +++ b/components/Input/Input.jsx @@ -7,7 +7,7 @@ class Input extends PureComponent { constructor(props) { super(props); this.state = { - length: 0, + length: (props.value || props.defaultValue || '').length, }; this.onInputChange = this.onInputChange.bind(this); } diff --git a/examples/pages/InputPage.jsx b/examples/pages/InputPage.jsx index 690a35cbb..e3fc39548 100644 --- a/examples/pages/InputPage.jsx +++ b/examples/pages/InputPage.jsx @@ -46,7 +46,7 @@ class Page extends Component { 显示输入字数 - +