微信小程序复制文本到剪切板

html

<view class="order_info_text">{{orderData.order_num}} <text class="copy" data-order_num="{{orderData.order_num}}" bind:tap="copy">复制</text> </view>

js

copy: function ({
  currentTarget: {
    dataset: { order_num }
  }
}) {
  console.log(order_num);
  wx.setClipboardData({
    //准备复制的数据
    data: order_num,
    success: function (res) {
      wx.showToast({
        title: ‘复制成功‘,
      });
    }
  });
}

微信小程序复制文本到剪切板

相关推荐