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);
|
||||
},
|
||||
focus () {
|
||||
if (this.type === 'textarea') {
|
||||
this.$refs.textarea.focus();
|
||||
} else {
|
||||
this.$refs.input.focus();
|
||||
focus (option) {
|
||||
const $el = this.type === 'textarea' ? this.$refs.textarea : this.$refs.input;
|
||||
$el.focus(option);
|
||||
// Selection content
|
||||
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 () {
|
||||
|
|
Loading…
Add table
Reference in a new issue