wx.setClipboardData({
data: 'data',
success: function(res) {
wx.getClipboardData({
success: function(res) {
console.log(res.data) // data
}
})
}
})
將要復制的內容放到data里面即可。
獲取系統剪貼板的內容
wx.getClipboardData({
success: function(res){
console.log(res.data)
}
})
Demo:
<text class="tblin_items_txt" selectable="true">{{detail.taokouling||''}}</text> <!-- 復制的對象-->
<view class="tblin_items_btn" bindtap="copyTBL">一鍵復制</view><!-- 復制操作 -->
Js:
copyTBL:function(e){
var self=this;
wx.setClipboardData({
data: self.data.taokouling,
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('取消')
}
}
})
}
});
}
文章來源:劉俊濤的博客
歡迎關注,有問題一起學習歡迎留言、評論。