From 351c0acbcf09cdd43ef430697273f350541b74fe Mon Sep 17 00:00:00 2001 From: Sure_TA <996712856@qq.com> Date: Mon, 21 Oct 2019 19:37:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(taro-h5):=20=E4=BF=AE=E5=A4=8Dh5=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8BsetClipboardData=E5=9C=A8ios=E6=97=A0?= =?UTF-8?q?=E6=95=88,=20=E5=9C=A8android=E6=BB=9A=E5=8A=A8=E5=88=B0?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=9C=80=E5=90=8E=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#4622)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-h5/src/api/clipboard/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/taro-h5/src/api/clipboard/index.js b/packages/taro-h5/src/api/clipboard/index.js index 99b36f4a90d8..23b2cc9f9e5d 100644 --- a/packages/taro-h5/src/api/clipboard/index.js +++ b/packages/taro-h5/src/api/clipboard/index.js @@ -54,11 +54,12 @@ export const setClipboardData = ({ data, success, fail, complete }) => { input.style.width = '100px' input.style.left = '-10000px' document.body.appendChild(input) - input.focus() - if (input.setSelectionRange) { - input.setSelectionRange(0, input.value.length) - document.execCommand('copy') - document.body.removeChild(input) + input.select() + input.setSelectionRange(0, 999999) + const results = document.execCommand('copy') + document.body.removeChild(input) + if (!results) { + throw new Error('复制失败') } } const res = {