We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
这是改进后的代码 export function setClipboardData(data) { return new Promise((success, fail) => { // #ifndef H5 uni.setClipboardData({ data, success, fail }) // #endif // #ifdef H5 const textarea = document.createElement('textarea') try { textarea.value = data textarea.readOnly = true document.body.appendChild(textarea) textarea.select() textarea.setSelectionRange(0, data.length) document.execCommand('copy') textarea.remove() success(data) } catch (error) { textarea.remove() fail(error) } // #endif }) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
这是改进后的代码
export function setClipboardData(data) {
return new Promise((success, fail) => {
// #ifndef H5
uni.setClipboardData({
data,
success,
fail
})
// #endif
// #ifdef H5
const textarea = document.createElement('textarea')
try {
textarea.value = data
textarea.readOnly = true
document.body.appendChild(textarea)
textarea.select()
textarea.setSelectionRange(0, data.length)
document.execCommand('copy')
textarea.remove()
success(data)
} catch (error) {
textarea.remove()
fail(error)
}
// #endif
})
}
The text was updated successfully, but these errors were encountered: