上周的项目中实现兑换功能,用于兑换码比较复制(英文大小写+数字),为方便用户兑换就实现了点击复制的功能
效果图:
实现的代码:
.wxml页面:
<view class='commission'>
<view class="number">
{ {exchangeKey}}
</view>
<view class="copy" bindtap='copyKey' data-text="{ {exchangeKey}}">点击复制</view>
</view>
.js页面:
Page({
data:{
exchangeKey:'YJL245sd5f'
},
copyKey: function (e) {
wx.setClipboardData({
data: e.currentTarget.dataset.text,
success: function (res) {
wx.getClipboardData