Merge pull request #192 from zhaouv/v2.x

fix textarea.select
This commit is contained in:
Zhang Chen 2018-08-26 23:27:26 +08:00 committed by GitHub
commit ab0bcd27bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -199,7 +199,8 @@ var copyMap = new Vue({
return;
}
try {
pout.select();
pout.focus();
pout.setSelectionRange(0, pout.value.length);
document.execCommand("Copy");
tip.whichShow = 6;
} catch (e) {

View File

@ -568,7 +568,8 @@ utils.prototype.copy = function (data) {
textArea.style.background = 'transparent';
textArea.value = data;
document.body.appendChild(textArea);
textArea.select();
textArea.focus();
textArea.setSelectionRange(0, textArea.value.length);
var successful = false;
try {
successful = document.execCommand('copy');