参考文档:https://developers.weixin.qq.com/miniprogram/dev/api/wx.getClipboardData.html
wxml代码:
<!-- 复制 -->
<view class='copy'>
<text class="follow" selectable="true">{{detailtaokouling||''}}</text><!-- 复制的内容 -->
<view class="name" bindtap="copyTBL">复制名称</view><!-- 点击复制 -->
</view>
js代码:
// 复制
copyTBL: function (e) {
var self = this;
wx.setClipboardData({
data: '搜索关注公众号, 获更好体验',//需要复制的内容
success: function (res) {
// self.setData({copyTip:true}),
wx.showModal({
title: '提示',
content: '复制成功',
success: function (res) {
if (res.confirm) {
console.log('确定')
} else if (res.cancel) {
console.log('取消')
}
}
})
}
});
}