Skip to content

Commit

Permalink
fix(taro-h5): 修复h5环境下setClipboardData在ios无效, 在android滚动到页面最后的问题 (#4622)
Browse files Browse the repository at this point in the history
  • Loading branch information
Liaozzzzzz authored and luckyadam committed Oct 21, 2019
1 parent f2aab37 commit 351c0ac
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/taro-h5/src/api/clipboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 351c0ac

Please sign in to comment.