wxml:
<view>内容:{{text}} </view>
<view bindtap='copyText' data-text="{{text}}">点击复制</view>
js:
Page({
data: {
contents:'今天天气不错!'
},
copyText: function (e) {
var text = e.currentTarget.dataset.text
wx.setClipboardData({
data: text,
success: function (res) {
wx.getClipboardData({
success: function (res) {
wx.showToast({
title: '复制成功'
})
}
})
}
})
},
})
网友评论