From 536887a7a74e75f7d09c4836bd314792a7e88170 Mon Sep 17 00:00:00 2001 From: wangxueliang Date: Thu, 17 Oct 2019 17:59:23 +0800 Subject: [PATCH] fix: input-password input-search no work --- components/input/Input.jsx | 2 -- .../input/{Password.js => Password.jsx} | 29 ++++++++++++++----- components/input/Search.jsx | 1 + 3 files changed, 23 insertions(+), 9 deletions(-) rename components/input/{Password.js => Password.jsx} (72%) diff --git a/components/input/Input.jsx b/components/input/Input.jsx index 5130c65df..aa7ed1c70 100644 --- a/components/input/Input.jsx +++ b/components/input/Input.jsx @@ -5,9 +5,7 @@ import inputProps from './inputProps'; import { hasProp, getComponentFromProp } from '../_util/props-util'; import { isIE, isIE9 } from '../_util/env'; import { ConfigConsumerProps } from '../config-provider'; -import Password from './Password'; import Icon from '../icon'; -import warning from '../_util/warning'; function noop() {} diff --git a/components/input/Password.js b/components/input/Password.jsx similarity index 72% rename from components/input/Password.js rename to components/input/Password.jsx index c7de5edec..256c78081 100644 --- a/components/input/Password.js +++ b/components/input/Password.jsx @@ -1,4 +1,5 @@ import classNames from 'classnames'; +import { getComponentFromProp, getOptionProps } from '../_util/props-util'; import Input from './Input'; import Icon from '../icon'; import inputProps from './inputProps'; @@ -57,19 +58,33 @@ export default { }, }, render() { - const { prefixCls, inputPrefixCls, size, suffix, visibilityToggle, ...restProps } = this.$props; + const { prefixCls, inputPrefixCls, size, suffix, visibilityToggle, ...restProps } = getOptionProps(this); const suffixIcon = visibilityToggle && this.getIcon(); const inputClassName = classNames(prefixCls, { [`${prefixCls}-${size}`]: !!size, }); + const inputProps = { + props: { + ...restProps, + prefixCls: inputPrefixCls, + size, + suffix: suffixIcon, + prefix: getComponentFromProp(this, 'prefix'), + addonAfter: getComponentFromProp(this, 'addonAfter'), + addonBefore: getComponentFromProp(this, 'addonBefore'), + }, + attrs: { + ...this.$attrs, + type: this.visible ? 'text' : 'password', + }, + class: inputClassName, + on: { + ...this.$listeners, + }, + }; return ( ); }, diff --git a/components/input/Search.jsx b/components/input/Search.jsx index 724e93d95..61cfba918 100644 --- a/components/input/Search.jsx +++ b/components/input/Search.jsx @@ -127,6 +127,7 @@ export default { prefixCls: inputPrefixCls, size, suffix: this.renderSuffix(prefixCls), + prefix: getComponentFromProp(this, 'prefix'), addonAfter: this.renderAddonAfter(prefixCls), addonBefore, },