3 回复
wxml代码:
< view > < text >{{contents}}</ text > </ view > < view bindtap = 'copyText' data-text = "{{contents}}" style = 'fcolor:#123;' >点击此处复制</ view > |
js代码:
Page({ data: { contents: "需要复制的内容" }, copyText: function (e) { console.log(e) wx.setClipboardData({ data: e.currentTarget.dataset.text, success: function (res) { wx.getClipboardData({ success: function (res) { wx.showToast({ title: '复制成功' }) } }) } }) }, }) |