提交 dff50832 编写于 作者: 北巷晴's avatar 北巷晴

h5复制功能

上级 1d17e18c
......@@ -7,7 +7,7 @@ Vue.mixin({
nickname: "游客",
portrait: "/static/missing-face.png",
phone: "欢迎您!",
walletaddress:""
walletaddress: ""
},
}
},
......@@ -45,6 +45,19 @@ Vue.mixin({
}
})
// #endif
//#ifdef H5
const result = this.h5Copy(getData)
if (result === false) {
uni.showToast({
title: '不支持',
})
} else {
uni.showToast({
title: '复制成功',
icon: 'none'
})
}
// #endif
},
// 数字前面补零
seqid00000(num, length) {
......@@ -53,5 +66,20 @@ Vue.mixin({
}
return num;
},
h5Copy(content) {
if (!document.queryCommandSupported('copy')) {
// 不支持
return false
}
let textarea = document.createElement("textarea")
textarea.value = content
textarea.readOnly = "readOnly"
document.body.appendChild(textarea)
textarea.select() // 选择对象
textarea.setSelectionRange(0, content.length) //核心
let result = document.execCommand("copy") // 执行浏览器复制命令
textarea.remove()
return result
}
}
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册