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


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) 以逗号分割 两侧不同的颜色
}

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM