diff --git a/examples/docs/en-US/input.md b/examples/docs/en-US/input.md index 044f42a844..9d489dcd7e 100644 --- a/examples/docs/en-US/input.md +++ b/examples/docs/en-US/input.md @@ -684,6 +684,13 @@ Search data from server-side. | change | triggers when the icon inside Input value change | (value: string \| number) | | clear | triggers when the Input is cleared by the button which generated by the "clearable" attribute | (event: Event) | +### Input Methods + +| Method | Description | Parameters | +|------|--------|-------| +| focus | focus the input element | — | +| select | select the text in input element | — | + ### Autocomplete Attributes Attribute | Description | Type | Options | Default @@ -718,7 +725,8 @@ Attribute | Description | Type | Options | Default |----| ----| ----| |select | triggers when a suggestion is clicked | suggestion being clicked | -### Methods +### Autocomplete Methods + | Method | Description | Parameters | |------|--------|-------| -| focus | focus the Input component | — | +| focus | focus the input element | — | diff --git a/examples/docs/es/input.md b/examples/docs/es/input.md index 82435f539c..d89935b198 100644 --- a/examples/docs/es/input.md +++ b/examples/docs/es/input.md @@ -663,6 +663,13 @@ Búsqueda de datos desde el servidor. | change | se activa cuando cambia el valor de entrada | (value: string \| number) | | clear | se dispara cuando la entrada es borrada por el botón generado por el atributo "clearable". | (event: Event) | +### Input Metodo + +| Metodo | Descripción | Parametros | +| ------ | ----------------------------- | ---------- | +| focus | coloca el foco en el elemento | — | +| select | select the text in input element | — | + ### Autocomplete Atributos Atributo | Descripción | Tipo | Opciones | Por defecto @@ -695,7 +702,8 @@ Atributo | Descripción | Tipo | Opciones | Por defecto | ------ | ---------------------------------------- | ---------------------------------------- | | select | se dispara cuando se hace click a una sugerencia | sugerencia en la que se está haciendo click | -### Metodo +### Autocomplete Metodo + | Metodo | Descripción | Parametros | | ------ | ----------------------------- | ---------- | | focus | coloca el foco en el elemento | — | diff --git a/examples/docs/zh-CN/input.md b/examples/docs/zh-CN/input.md index 7153ef70eb..84b7516ac3 100644 --- a/examples/docs/zh-CN/input.md +++ b/examples/docs/zh-CN/input.md @@ -841,7 +841,8 @@ export default { ### Input Methods | 方法名 | 说明 | 参数 | | ---- | ---- | ---- | -| focus | 使 input 获取焦点 | - | +| focus | 使 input 获取焦点 | — | +| select | 选中 input 中的文字 | — | ### Autocomplete Attributes @@ -873,3 +874,8 @@ export default { | 事件名称 | 说明 | 回调参数 | |---------|--------|---------| | select | 点击选中建议项时触发 | 选中建议项 | + +### Autocomplete Methods +| 方法名 | 说明 | 参数 | +| ---- | ---- | ---- | +| focus | 使 input 获取焦点 | - | diff --git a/packages/input/src/input.vue b/packages/input/src/input.vue index 7b45dc03f3..0b42433341 100644 --- a/packages/input/src/input.vue +++ b/packages/input/src/input.vue @@ -229,7 +229,7 @@ this.dispatch('ElFormItem', 'el.form.blur', [this.currentValue]); } }, - inputSelect() { + select() { (this.$refs.input || this.$refs.textarea).select(); }, resizeTextarea() { @@ -291,7 +291,7 @@ }, created() { - this.$on('inputSelect', this.inputSelect); + this.$on('inputSelect', this.select); }, mounted() { diff --git a/types/input.d.ts b/types/input.d.ts index 6f0888cad7..e6e76e4f76 100644 --- a/types/input.d.ts +++ b/types/input.d.ts @@ -79,4 +79,9 @@ export declare class ElInput extends ElementUIComponent { * Focus the Input component */ focus (): void + + /** + * Select the text in input element + */ + select (): void }