看了github还有很多平台,上面都需要下插件才可以使用复制或者粘贴功能,但是Nuxt中已经设置好了这些api可以直接调用即可
navigator.clipboard.writeText(InvitationCode.value)
这个是将内容复制到剪贴板上,返回一个promise对象,可以使用.then和.catch在判断失败或者成功的回调,
navigator.clipboard.writeText(InvitationCode.value).then(res => {
getNotification('消息', '复制成功', 'success')
}).catch(error => {
getNotification('消息', '复制失败、请联系管理员', 'error')
})
将剪贴板中的内容粘贴到页面上,用
navigator.clipboard.readText()
他也返回一个promise对象,同样使用.then和.catch