diff --git a/components/auto-complete/InputElement.jsx b/components/auto-complete/InputElement.jsx index ab84209e2..2ba4e1a4e 100644 --- a/components/auto-complete/InputElement.jsx +++ b/components/auto-complete/InputElement.jsx @@ -18,6 +18,7 @@ export default { props: { value: PropTypes.any, disabled: PropTypes.bool, + placeholder: PropTypes.string, }, methods: { focus() { @@ -31,7 +32,7 @@ export default { }, render() { - const { $slots = {}, $attrs = {} } = this; + const { $slots = {}, $attrs = {}, placeholder } = this; const listeners = getListeners(this); const props = getOptionProps(this); const value = props.value === undefined ? '' : props.value; @@ -43,14 +44,20 @@ export default { for (const [eventName, event] of Object.entries(listeners)) { newEvent[eventName] = chaining(event, events[eventName]); } - + const attrs = { ...$attrs, value }; + // https://github.com/vueComponent/ant-design-vue/issues/1761 + delete props.placeholder; + if (placeholder) { + props.placeholder = placeholder; + attrs.placeholder = placeholder; + } return cloneElement(children, { domProps: { value, }, props, on: newEvent, - attrs: { ...$attrs, value }, + attrs, ref: 'ele', }); }, diff --git a/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap b/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap index c96a8fb2a..0c067869c 100644 --- a/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap +++ b/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap @@ -4,10 +4,9 @@ exports[`renders ./components/auto-complete/demo/basic.md correctly 1`] = `