wxml
<view class="title">传感器</view>
<view class="demo-box">
<view class="title">剪贴板</view>
<view class="title">{{code}}</view>
<button type="primary" bindtap="setClipboard">点击此处复制上列序号</button>
<button bindtap="getClipboard">获取剪贴板内容</button>
</view>
js
Page({
data: {
code:'121243243e'
},
setClipboard:function(){
let code=this.data.code
wx.setClipboardData({
data: code,
success:function(){
wx.showToast({
title: '复制成功',
})
}
})
},
getClipboard:function(){
wx.getClipboardData({
success:function(res){
wx.showToast({
title: '剪贴板内容是:'+res.data,
icon:'none'
})
},
})
},
)}