diff --git a/packages/taro-components/src/components/input/input.tsx b/packages/taro-components/src/components/input/input.tsx index d5f26d22487f..9b9406f6cd85 100644 --- a/packages/taro-components/src/components/input/input.tsx +++ b/packages/taro-components/src/components/input/input.tsx @@ -44,12 +44,19 @@ export class Input implements ComponentInterface { @Element() el: HTMLElement @Watch('value') - watchHandler(newValue: string, oldValue: string) { + watchHandler (newValue: string, oldValue: string) { if (newValue !== oldValue) { this._value = newValue } } + @Watch('autoFocus') + watchFocus (newValue: boolean, oldValue: boolean) { + if (!oldValue && newValue) { + this.inputRef.focus() + } + } + @Event({ eventName: 'input' }) onInput: EventEmitter