微信小程序复制文字

2022-08-03  本文已影响0人  xsmile21

需求:复制运单编号
方法:wx.setClipboardData


<view class="prize" wx:for="{{ prizeList }}" wx:key="id">
    ......
    <view class="copy" bindtap="copy" data-title="{{ item.waybillNumber }}" wx:if="{{ item.waybillNumber }}">复制</view>
</view>
// 复制
copy(e) {
  let query = e.currentTarget.dataset['title'];
  console.log(query);
  wx.setClipboardData({
      data: query,
      success: function (res) {
         wx.showToast({
            title: '复制成功',
            icon: 'none',
            mask: 'true'
         })
      }
   })
}
上一篇 下一篇

猜你喜欢

热点阅读