From 3377cd0847cb313a1bcc782a89f331c893cb4136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=A5=95?= <Leopoldthecoder@users.noreply.github.com> Date: Mon, 19 Mar 2018 12:17:57 +0800 Subject: [PATCH] Input: add select method (#10229) --- examples/docs/en-US/input.md | 12 ++++++++++-- examples/docs/es/input.md | 10 +++++++++- examples/docs/zh-CN/input.md | 8 +++++++- packages/input/src/input.vue | 4 ++-- types/input.d.ts | 5 +++++ 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/examples/docs/en-US/input.md b/examples/docs/en-US/input.md index 044f42a84..9d489dcd7 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 82435f539..d89935b19 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 7153ef70e..84b7516ac 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 7b45dc03f..0b4243334 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 6f0888cad..e6e76e4f7 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 }