index.js代码
Page({
/* 页面的初始数据 */
data: {
order_ids: "http://t.cn/Rgh0o1T"
},
// 一键复制事件
copyBtn: function (e) {
var that = this;
wx.setClipboardData({
//准备复制的数据
data:that.data.order_ids,
success: function (res) {
wx.showToast({
title: '复制成功',
});
}
});
}
})
index.wxml中代码
!-- 标签名称 --
text selectable='true' bindlongtap='copy'{{order_ids}}/text
!-- 复制 --
label class='lab_copy' bindtap='copyBtn'复制/label
注:如果单纯是长按复制文案,直接在text中加入一个selectable='true'属性就行













