微信小程序復制功能以及背景顏色漸變實現


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