Input method focus add Selection content
This commit is contained in:
parent
cb82a97d88
commit
3fde9d0006
1 changed files with 18 additions and 5 deletions
|
@ -342,11 +342,24 @@
|
||||||
|
|
||||||
this.textareaStyles = calcTextareaHeight(this.$refs.textarea, minRows, maxRows);
|
this.textareaStyles = calcTextareaHeight(this.$refs.textarea, minRows, maxRows);
|
||||||
},
|
},
|
||||||
focus () {
|
focus (option) {
|
||||||
if (this.type === 'textarea') {
|
const $el = this.type === 'textarea' ? this.$refs.textarea : this.$refs.input;
|
||||||
this.$refs.textarea.focus();
|
$el.focus(option);
|
||||||
} else {
|
// Selection content
|
||||||
this.$refs.input.focus();
|
const { cursor } = option || {};
|
||||||
|
if (cursor) {
|
||||||
|
const len = $el.value.length;
|
||||||
|
|
||||||
|
switch (cursor) {
|
||||||
|
case 'start':
|
||||||
|
$el.setSelectionRange(0, 0);
|
||||||
|
break;
|
||||||
|
case 'end':
|
||||||
|
$el.setSelectionRange(len, len);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$el.setSelectionRange(0, len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
blur () {
|
blur () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue