微信小程序复制功能以及背景颜色渐变实现

1.复制功能可以参照官方文档,

 copytext: function() {
    var that = this;
    wx.setClipboardData({
      data: that.data.shareresult.content,
      success: function(res) {
        if (res.confirm) {
          console.log(\'确定\')
        } else if (res.cancel) {
          console.log(\'取消\')
        }
      }
    });
  },

 2.背景颜色渐变实现

-->wxml

<view class=\'copyBtn\' bindtap="copytext">复制文字</view>

-->wxss

 background: linear-gradient(to right, #3d6aea, #7318d9);/
.copyBtn {
  margin: 35rpx auto;
  width: 240rpx;
  height: 60rpx;
  text-align: center;
  line-height: 60rpx;
  border-radius: 30rpx;
  color: #fff;
  background: linear-gradient(to right, #3d6aea, #7318d9);//使用linear-gradient 指定方向(to right/to left) 以逗号分割 两侧不同的颜色
}