提交 243c069f 编写于 作者: D DCloud_LXH

feat: setClipboardData 支持配置是否弹出提示

上级 5e2caae8
......@@ -204,7 +204,7 @@ function createApiCallback (apiName, params = {}, extras = {}) {
const errMsg = res.errMsg
if (errMsg.indexOf(apiName + ':ok') === 0) {
isFn(beforeSuccess) && beforeSuccess(res)
isFn(beforeSuccess) && beforeSuccess(res, params)
hasSuccess && success(res)
......
......@@ -3,11 +3,20 @@ import {
} from 'uni-core/helpers/i18n'
export const setClipboardData = {
beforeSuccess () {
data: {
type: String,
required: true
},
showToast: {
type: Boolean,
default: true
},
beforeSuccess (res, params) {
if (!params.showToast) return
const title = t('uni.setClipboardData.success')
if (title) {
uni.showToast({
title: t('uni.setClipboardData.success'),
title,
icon: 'success',
mask: false,
style: {
......
......@@ -22,7 +22,7 @@ export function setClipboardData ({
const textarea = document.createElement('textarea')
textarea.id = '#clipboard'
textarea.style.position = 'absolute'
textarea.style.top = '0'
textarea.style.top = '-9999px'
textarea.style.zIndex = '-9999'
document.body.appendChild(textarea)
textarea.value = data
......@@ -30,10 +30,6 @@ export function setClipboardData ({
textarea.select()
const result = document.execCommand('Copy', false, null)
if (result) {
uni.showToast({
title: '复制成功',
icon: 'none'
})
return {
errMsg: 'setClipboardData:ok'
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册